A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
15
Task/Function-composition/Fantom/function-composition.fantom
Normal file
15
Task/Function-composition/Fantom/function-composition.fantom
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
class Compose
|
||||
{
|
||||
static |Obj -> Obj| compose (|Obj -> Obj| fn1, |Obj -> Obj| fn2)
|
||||
{
|
||||
return |Obj x -> Obj| { fn2 (fn1 (x)) }
|
||||
}
|
||||
|
||||
public static Void main ()
|
||||
{
|
||||
double := |Int x -> Int| { 2 * x }
|
||||
|Int -> Int| quad := compose(double, double)
|
||||
echo ("Double 3 = ${double(3)}")
|
||||
echo ("Quadruple 3 = ${quad (3)}")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue