Skip to content

Instantly share code, notes, and snippets.

@wofockham
Created September 24, 2013 10:05
Show Gist options
  • Save wofockham/6682740 to your computer and use it in GitHub Desktop.
Save wofockham/6682740 to your computer and use it in GitHub Desktop.
@env = { :label => proc { |(name,val), _| @env[name] = eval(val, @env) },
:car => lambda { |(list), _| list[0] },
:cdr => lambda { |(list), _| list.drop 1 },
:cons => lambda { |(e,cell), _| [e] + cell },
:eq => lambda { |(l,r), ctx| eval(l, ctx) == eval(r, ctx) },
:if => proc { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) },
:atom => lambda { |(sexpr), _| (sexpr.is_a? Symbol) or (sexpr.is_a? Numeric) },
:quote => proc { |sexpr, _| sexpr[0] } }.merge(ext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment