1.47. Lambda expressions

Felix allows a function to be specified in an expression, this is called a lambda expression:
Start felix section to tut/examples/tut_beg156.flx[1 /1 ]
     1: #line 2491 "./lpsrc/flx_tutorial.pak"
     2: #import <flx.flxh>
     3: var x = 10;
     4: while
     5:   (fun ():bool = { return x>0; })
     6:   { print x; endl; x = x - 1; };
     7: 
End felix section to tut/examples/tut_beg156.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 felix section to tut/examples/tut_beg157.flx[1 /1 ]
     1: #line 2503 "./lpsrc/flx_tutorial.pak"
     2: #import <flx.flxh>
     3: fun f(g:int->int,x:int) = { return g x; }
     4: print
     5: (
     6:   f
     7:   (
     8:     (fun(a:int):int = { return a + a; }),
     9:     1
    10:   )
    11: ); endl;
    12: 
    13: 
End felix section to tut/examples/tut_beg157.flx[1]