Anonymous recursion: Difference between revisions

Line 324:
(run (cdr recurse)) )</lang>
Note how 'recur' dynamically defines the function 'recurse' at runtime, by binding the rest of the expression (i.e. the body of the 'recur' statement) to the symbol 'recurse'.
 
=={{header|PostScript}}==
{{libheader|postscript}}
Postscript can make use of the higher order combinators to provide recursion.
<lang postscript>
% primitive recursion
/pfact {
{1} {*} primrec}.
 
%linear recursion
/lfact {
{dup 0 eq}
{pop 1}
{dup pred}
{*}
linrec}.
 
% general recursion
/gfact {
{0 eq}
{succ}
{dup pred}
{i *}
genrec}.
 
% binary recursion
/fib {
{2 lt} {} {pred dup pred} {+} binrec}.
</lang>
 
=={{header|Python}}==
418

edits