1.46. Lambda expressions

Felix allows a function to be specified in an expression, this is called a lambda expression:
Start C++ section to tut/examples/tut156.flx[1 /1 ]
     1: include "std";
     2: var x = 10;
     3: while
     4:   (fun ():bool = { return x>0; })
     5:   { print x; endl; x = x - 1; };
     6: 
End C++ section to tut/examples/tut156.flx[1]
Of course, we have already used lambdas in the short form, by enclosing expressions in curley braces; this example shows the long form. Lambdas of course may have arguments:
Start C++ section to tut/examples/tut157.flx[1 /1 ]
     1: include "std";
     2: fun f(g:int->int,x:int) = { return g x; }
     3: print
     4: (
     5:   f
     6:   (
     7:     (fun(a:int):int = { return a + a; }),
     8:     1
     9:   )
    10: ); endl;
    11: 
    12: 
End C++ section to tut/examples/tut157.flx[1]