Skip to content

Instantly share code, notes, and snippets.

@TannerRogalsky
Created July 24, 2012 15:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TannerRogalsky/3170712 to your computer and use it in GitHub Desktop.
Save TannerRogalsky/3170712 to your computer and use it in GitHub Desktop.
Auto-memoizing Fibonacci sequence in lua metatables
fib = setmetatable({1, 1},
{__index = function(t,n)
t[n] = t[n-1] + t[n-2]
return t[n]
end})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment