Created
March 4, 2011 18:29
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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