3 ms·
If you are going to go any distance into the functions as first-class citizens path then it might not be too much of a diversion to show a function that generat
by evgen 17y ago
If you are going to go any distance into the functions as first-class citizens path then it might not be too much of a diversion to show a function that generates functions and then bounce quickly to simple currying as a more advanced example of this. You would not even need to describe it as currying..
- loup-vaillant 17y agoPlus, first class functions can be shown with mere high school mathematics. Lambda are really easy: the f: R -> R x |-> blah(x) you find in high school would be f : (float -> float) = fun x -> blah x In Ocaml (and probably F#). The composition operator can easily be seen as a function with two arguments, which show "first class" functions: o : (R->R), (R->R) -> (R -> R ) (f , g ) |-> (x |-> f(g(x))) And poof, you can introduce currying: o : ((R->R), (R->R) , R) -> R (f , g , x) |-> f(g(x)))