StdFunctions.dcl 1.07 KB
 John van Groningen committed Aug 14, 2018 1 2 3 4 5 6 7 ``````definition module StdFunctions // **************************************************************************************** // Concurrent Clean Standard Library Module Version 3.0 // Copyright 2018 Radboud University // **************************************************************************************** `````` Camil Staps committed Dec 11, 2019 8 9 10 11 ``````//* The identity function. id :: !.a -> .a //* Always returns the first argument. const :: !.a .b -> .a `````` John van Groningen committed Aug 14, 2018 12 `````` `````` Camil Staps committed Dec 11, 2019 13 14 15 16 ``````/** * Flips the arguments of a function. This is useful in function compositions. * @type !.(.a -> .(.b -> .c)) .b .a -> .c */ `````` John van Groningen committed Aug 14, 2018 17 18 ``````flip f a b :== f b a `````` Camil Staps committed Dec 11, 2019 19 20 21 22 23 ``````/** * Function composition: apply `f` after `g`. * @type u:(.a -> .b) u:(.c -> .a) -> u:(.c -> .b) */ (o) infixr 9 `````` John van Groningen committed Aug 14, 2018 24 25 ``````(o) f g :== \ x -> f (g x) `````` Camil Staps committed Dec 11, 2019 26 27 28 29 30 31 32 33 ``````//* Apply the function argument twice. twice :: !(.a -> .a) .a -> .a //* Apply the second argument as long as the first argument holds. while :: !(a -> .Bool) (a -> a) a -> a //* Apply the second argument until the first argument holds. until :: !(a -> .Bool) (a -> a) a -> a //* Apply a function a number of times. iter :: !Int (.a -> .a) .a -> .a``````