Skip to content

Instantly share code, notes, and snippets.

View p8's full-sized avatar

Petrik de Heus p8

View GitHub Profile
@p8
p8 / lithp.rb
Created January 26, 2012 00:34 — forked from fogus/lithp.rb
class Lisp
Fs = {
:label => lambda {|name,value| Fs[name] = lambda { value } },
:car => lambda {|sexp| sexp.first },
:cdr => lambda {|sexp| sexp.slice(1, sexp.size) },
:cons => lambda {|head,tail| [head] + tail },
:atom => lambda {|sexp| !sexp.is_a?(Array) },
:eq => lambda {|a,b| a == b },
:if => lambda {|cnd,thn,els| cnd ? thn : els }
}