Given a function f
of three arguments, whose type is described as
f :: (X,Y,Z) -> Rthe following table shows some of the different ways that
f
can be used. Each row of the table shows different ways
to express the same thing, using the various currying styles available
in FC++. Note that the "prefix" and "underscore" styles can only be
used on Curryable
s, whereas the "binder" and "curry"
styles can be used on any functoid.
Prefix ( Curryable s) |
Underscore ( Curryable s) |
Binder (all functoids) |
Curry (all functoids) |
Result Type |
f(x) |
f(x,_,_) |
bind1of3(f,x) |
curry3(f,x) |
(Y,Z)->R |
f(_,_,z) |
bind3of3(f,z) |
(X,Y)->R |
||
f(x,y) |
f(x,y,_) |
bind1and2of3(f,x,y) |
curry3(f,x,y) |
(Z)->R |
f(_,y,z) |
bind2and3of3(f,y,z) |
(X)->R |
||
bind1and2and3of3(f,x,y,z) |
curry3(f,x,y,z) |
()->R |
||
f(x,y,z) |
f(x,y,z) |
R |
The practical offshoot of this is that it's easy to express some simple functions:
plus(3) // f(x) = 3 + x greater(_,10) // f(x) = x > 10 map(inc) // a function which inc's all elements of a list until(prime,inc) // f(x) = first prime number that's >= x