Anonymous recursion: Difference between revisions

Line 2,337:
fib n => switch n {
< 0 => str.format 'Bad argument: {q}' n;
default => n -> (@ memo s n => switch n {
== 0 => 0; == 1 => 1;
default => + (s (- n 1)) (s (- n 2));
Line 2,343:
};</lang>
 
In WDTE, a lambda, defined in thea block deliniated by <code>(@)</code>, gets passed itself as its first argument, allowing for recursion. Like a 'normal' function, lambdas can be memoized using the <code>memo</code> keyword.
 
=={{header|Wren}}==