+
1
|
list
|
skin
|
login
|
editor
α-wwwiki
::
lambda
user:none
(1629 bytes)
_h1 lambda {span {@ style="font-size:0.6em;"}(see [[define]] and [[defun]])} _p When a function has to be used once inline, anonymous functions make things easier. {pre 1) The square function is not defined in the lambdatalk's core. It can be first created via the define operator and then used : °°{define square (x) return x*x;}°° -> {define square (x) return x*x;} °°{square 12}°° -> {square 12} And it can be created and used via the lambda operator : °°{{lambda (x) return x*x;} 12}°° -> {{lambda (x) return x*x;} 12} 2) A lambda function can be mapped to a serie of values : °°{map {lambda (x) return x*x*x;} {serie 1 10} } °°-> {map {lambda (x) return x*x*x;} {serie 1 10} } 3) Two ways to call Javascript Math functions : Via the define operator : °°{define cos (x) return Math.cos(Math.PI/180*x);}°° -> {define cos (x) return Math.cos(Math.PI/180*x);} °°{cos 45}°° -> {cos 45} Via the lambda operator : °°{{lambda (x) return Math.cos(Math.PI/180*x);} 45}°° -> {{lambda (x) return Math.cos(Math.PI/180*x);} 45} } _p Yes, alphawiki doesn't forget ze lambdaway :) :) _h3 alpha _p The "define" and "defun" operators follow a similar syntax, the first using Javascript expressions, the last using lambdatalk expressions. In a similar way, beside the "lambda" operator using Javascript expressions exists an "alpha" operator using lambdatalk expressions. More to say later about that. _h3 notes _ul Some synonyms for lambda : anonymous, fleeting, in short, transitory, fugitive, furtive, reducing, temporary, moving, momentary.