Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Lisp is fun!

Name: Alexander Dubček 2015-03-24 6:14

I wrote a toy Lisp interpreter this weekend. Programming is pretty much a video game!

https://bitbucket.org/dhoskin/thp

(LET ((f (LAMBDA (x) (IF (x (f (CDR x))) recursion!))))
(f (QUOTE (a b c d e))))

→ args: ((a b c d e))
→ args: ((b c d e))
→ args: ((c d e))
→ args: ((d e))
→ args: ((e))
→ args: (nil)
→ recursion!

Name: Alexander Dubček 2015-03-26 7:06

Huh, apparently my interpreter is smarter than I am.

Something that I knew would work:
(LET ((x 10) (f (LAMBDA () x)) (g (LAMBDA (x f) (f))))
(g 20 f)
→ 10


Something that I thought would break:
(LET ((x 10) (g (LAMBDA (x f) (f))))
(g 20 (LAMBDA () x)))
→ 10


I expected it to mistakenly print 20.

Let's investigate...
(LET ((x 10) (g (LAMBDA (x f) f)))
(g 20 (LAMBDA () x)))
→ (CLOSURE ((x 10) (g (CLOSURE ((x 10)) (x f) f)) (x 10)) nil x)


Neat!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List