RosettaCodeData/Task/Anonymous-recursion/Lingo/anonymous-recursion-1.lingo

13 lines
356 B
Plaintext

on fib (n)
if n<0 then return _player.alert("negative arguments not allowed")
-- create instance of unnamed class in memory only (does not pollute namespace)
m = new(#script)
r = RETURN
m.scriptText = "on fib (me,n)"&r&"if n<2 then return n"&r&"return me.fib(n-1)+me.fib(n-2)"&r&"end"
aux = m.script.new()
m.erase()
return aux.fib(n)
end