Skip to content

Instantly share code, notes, and snippets.

@JoergWMittag
Created March 4, 2011 18:29
Show Gist options
  • Save JoergWMittag/855449 to your computer and use it in GitHub Desktop.
Save JoergWMittag/855449 to your computer and use it in GitHub Desktop.
Cons lists implemented as lambdas in Seph, see http://JoergWMittag.GitHub.Com/lambdaconscarcdr/
;; This is the Ioke code for comparison.
;; See <http://JoergWMittag.GitHub.Com/lambdaconscarcdr/> for
;; what this is supposed to do.
cons = fn(hd, tl, fn(x, if(x, hd, tl)))
car = fn(l, l(true ))
cdr = fn(l, l(false))
l = cons(1, cons(2, nil))
car(cdr(l)) println
;; See <http://JoergWMittag.GitHub.Com/lambdaconscarcdr/> for
;; what this is supposed to do.
cons = #(hd, tl, #(x, if(x, hd, tl)))
car = #(l, l(true ))
cdr = #(l, l(false))
l = cons(1, cons(2, nil))
car(cdr(l)) println
;; This doesn't actually *run*, because the compiler is missing
;; some necessary functionality, but it should be *correct* (i.e.
;; it *will* run once the compiler matures.
;;
;; Currently, the errors are:
;; couldn't find: x on seph.lang.Ground
;; couldn't find: nil on seph.lang.Ground
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment