diff --git a/Libraries/StdEnv/StdFunc.dcl b/Libraries/StdEnv/StdFunc.dcl index 354a6516ac20fa962c385391c47a909ae623b2cd..1a98fd69e1b35ad2b5359eb5c6471f7002568e36 100644 --- a/Libraries/StdEnv/StdFunc.dcl +++ b/Libraries/StdEnv/StdFunc.dcl @@ -1,23 +1,11 @@ definition module StdFunc // **************************************************************************************** -// Concurrent Clean Standard Library Module Version 2.0 -// Copyright 1998 University of Nijmegen +// Concurrent Clean Standard Library Module Version 3.0 +// Copyright 2018 Radboud University // **************************************************************************************** -id :: !.a -> .a // identity function -const :: !.a .b -> .a // constant function - -//flip :: !.(.a -> .(.b -> .c)) .b .a -> .c // Flip arguments -flip f a b :== f b a - -(o) infixr 9 // :: u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b) // Function composition -(o) f g :== \ x -> f (g x) - -twice :: !(.a -> .a) .a -> .a // 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) -iter :: !Int (.a -> .a) .a -> .a // f (f..(f x)..) +import StdFunctions // Some handy functions for transforming unique states: diff --git a/Libraries/StdEnv/StdFunc.icl b/Libraries/StdEnv/StdFunc.icl index 20c6471380e1b240aca0a135152cd1945d29d7c3..4381a9945b90bb36e9ab572a27707e72881fc223 100644 --- a/Libraries/StdEnv/StdFunc.icl +++ b/Libraries/StdEnv/StdFunc.icl @@ -1,42 +1,13 @@ implementation module StdFunc // **************************************************************************************** -// Concurrent Clean Standard Library Module Version 2.0 -// Copyright 1995 University of Nijmegen +// Concurrent Clean Standard Library Module Version 3.0 +// Copyright 2018 University of Nijmegen // **************************************************************************************** import StdClass, StdMisc, StdInt -id :: !.a -> .a -id x = x - -const :: !.a .b -> .a -const x y = x - -//flip::!.(.a -> .(.b -> .c)) .b .a -> .c -flip f a b :== f b a - -(o) infixr 9; // :: u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b) -(o) f g :== \ x -> f (g x) - -twice :: !(.a -> .a) .a -> .a -twice f x = f (f x) - -while :: !(a -> .Bool) (a -> a) a -> a -while p f x - | p x = while p f (f x) - = x - -until::!(a -> .Bool) (a -> a) a -> a -until p f x - | p x = x - = until p f (f x) - -iter :: !Int (.a -> .a) .a -> .a -iter 0 f x = x -iter n f x - | n > 0 = iter (n-1) f (f x) - = abort "Error: Negative index given to iter." +import StdFunctions seq :: ![.(.s -> .s)] .s -> .s seq [f:fs] arg = seq fs (f arg)