Title here
Summary here
(let compose (fun (_f _g) (...)))
Compose function calls
_f
: the first function_g
: the second function(let foo (fun (a) (* a a)))
(let bar (fun (b) (+ b b)))
(let composed (compose foo bar))
(print (composed 12)) # return value is (12 + 12) * (12 + 12)
(let left (fun (_x) (...)))
Take a value as its argument and return a function taking 2 arguments which will call the first function on the value
_x
: the value(let val (left 12))
(val (fun (x) (print x " i am called")) (fun (x) (print x " i am NOT called")))
(let right (fun (_y) (...)))
Take a value as its argument and return a function taking 2 arguments which will call the second function on the value
_y
: the value(let val (right 12))
(val (fun (x) (print x " i am NOT called")) (fun (x) (print x " i am called")))
(let flip (fun (_f _a) (...)))
Flip the arguments of a function
Note: Returns a function taking 1 argument: the second argument of the function to flip
_f
: the function_a
: the first argument(let foo (fun (a b) (- a b)))
((flip foo 14) 12) # will call (foo 12 14) instead of (foo 14 12)