Anonymous recursion: Difference between revisions
Content deleted Content added
Add Seed7 example |
jq |
||
Line 981:
})(n);
}</lang>
=={{header|jq}}==
As is the case, for example, with Julia, jq allows you to define an inner/nested function (here, <code>aux</code>) that is only defined within the surrounding function <code>fib</code> scope. Thus using such auxiliary functions does not cause name space pollution.
<lang jq>def fib(n):
def aux: if . == 0 then 0
elif . == 1 then 1
else (. - 1 | aux) + (. - 2 | aux)
end;
if n < 0 then error("negative arguments not allowed")
else n | aux
end ;</lang>
=={{header|Julia}}==
|