Commit be55ff24 authored by John van Groningen's avatar John van Groningen Committed by Camil Staps

add EOL property

parent d0ff967a
definition module StdFunctions definition module StdFunctions
// **************************************************************************************** // ****************************************************************************************
// Concurrent Clean Standard Library Module Version 3.0 // Concurrent Clean Standard Library Module Version 3.0
// Copyright 2018 Radboud University // Copyright 2018 Radboud University
// **************************************************************************************** // ****************************************************************************************
id :: !.a -> .a // identity function id :: !.a -> .a // identity function
const :: !.a .b -> .a // constant function const :: !.a .b -> .a // constant function
//flip :: !.(.a -> .(.b -> .c)) .b .a -> .c // Flip arguments //flip :: !.(.a -> .(.b -> .c)) .b .a -> .c // Flip arguments
flip f a b :== f b a flip f a b :== f b a
(o) infixr 9 // :: u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b) // Function composition (o) infixr 9 // :: u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b) // Function composition
(o) f g :== \ x -> f (g x) (o) f g :== \ x -> f (g x)
twice :: !(.a -> .a) .a -> .a // f (f x) twice :: !(.a -> .a) .a -> .a // f (f x)
while :: !(a -> .Bool) (a -> a) a -> a // while (p x) f (f x) while :: !(a -> .Bool) (a -> a) a -> a // while (p x) f (f x)
until :: !(a -> .Bool) (a -> a) a -> a // f (f x) until (p x) until :: !(a -> .Bool) (a -> a) a -> a // f (f x) until (p x)
iter :: !Int (.a -> .a) .a -> .a // f (f..(f x)..) iter :: !Int (.a -> .a) .a -> .a // f (f..(f x)..)
implementation module StdFunctions implementation module StdFunctions
// **************************************************************************************** // ****************************************************************************************
// Concurrent Clean Standard Library Module Version 3.0 // Concurrent Clean Standard Library Module Version 3.0
// Copyright 2018 Radbound University // Copyright 2018 Radbound University
// **************************************************************************************** // ****************************************************************************************
import StdClass, StdMisc, StdInt import StdClass, StdMisc, StdInt
id :: !.a -> .a id :: !.a -> .a
id x = x id x = x
const :: !.a .b -> .a const :: !.a .b -> .a
const x y = x const x y = x
//flip::!.(.a -> .(.b -> .c)) .b .a -> .c //flip::!.(.a -> .(.b -> .c)) .b .a -> .c
flip f a b :== f b a flip f a b :== f b a
(o) infixr 9; // :: u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b) (o) infixr 9; // :: u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b)
(o) f g :== \ x -> f (g x) (o) f g :== \ x -> f (g x)
twice :: !(.a -> .a) .a -> .a twice :: !(.a -> .a) .a -> .a
twice f x = f (f x) twice f x = f (f x)
while :: !(a -> .Bool) (a -> a) a -> a while :: !(a -> .Bool) (a -> a) a -> a
while p f x while p f x
| p x = while p f (f x) | p x = while p f (f x)
= x = x
until::!(a -> .Bool) (a -> a) a -> a until::!(a -> .Bool) (a -> a) a -> a
until p f x until p f x
| p x = x | p x = x
= until p f (f x) = until p f (f x)
iter :: !Int (.a -> .a) .a -> .a iter :: !Int (.a -> .a) .a -> .a
iter 0 f x = x iter 0 f x = x
iter n f x iter n f x
| n > 0 = iter (n-1) f (f x) | n > 0 = iter (n-1) f (f x)
= abort "Error: Negative index given to iter." = abort "Error: Negative index given to iter."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment