Skip to content

Instantly share code, notes, and snippets.

@r8d8
Last active July 6, 2018 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r8d8/32ddc199c73e22cec1355aa98d922e45 to your computer and use it in GitHub Desktop.
Save r8d8/32ddc199c73e22cec1355aa98d922e45 to your computer and use it in GitHub Desktop.
Lisp in Lua
function eval(x)
if type(x)=="table" then
return eval(x[1])(eval(x[2]),eval(x[3]))
else
return x
end
end
function add(x,y) return x+y end
function sub(x,y) return x-y end
function mul(x,y) return x*y end
function div(x,y) return x/y end
function pow(x,y) return x^y end
-- an example
function E(x) print(eval(x)) end
E{add,1,{mul,2,3}}
E{sin,60}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment