Anonymous user
Anonymous recursion: Difference between revisions
→{{header|Mathematica}} / {{header|Wolfram Language}}
(→{{header|BQN}}: Internal names) |
|||
Line 1,818:
{1, 1, 2, 3, 5}</lang>
=={{header|Matlab}}==
Not anonymous exactly, but using a nested function solves all the problems stated in the task description.
* does not exist outside of parent function
* does not need a new name, can reuse the parent name
* a nested function can be defined in the place where it is needed
<lang Matlab>
function v = fibonacci(n)
assert(n >= 0,"negative n")
v = fibonacci(n,0,1);
% nested function
function a = fibonacci(n,a,b)
if n ~= 0
a = fibonacci(n-1,b,a+b);
end
end
end
</lang>
=={{header|Nemerle}}==
|