Re:Ask HN: Functional Programming Differences
by evgen on Sunday March 07, 2010 @10:28PM
(#1174576)
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..
[ Parent
| on HN ]
Re:Ask HN: Functional Programming Differences
by loup-vaillant on Monday March 08, 2010 @03:35AM
(#1174997)
Plus, 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)))