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

Pages: 1-

lambda, brainf*ck machine, y combinator...

Name: Anonymous 2011-08-20 9:01

I'll just bookmark this here:
http://matt.might.net/articles/implementing-a-programming-language/

Below is the 7-line, 3-minute interpreter for the lambda calculus, in R5RS Scheme. In technical terms (explained below), it's an environment-based denotational interpreter.


; eval takes an expression and an environment to a value
(define (eval e env) (cond
  ((symbol? e)       (cadr (assq e env)))
  ((eq? (car e) 'λ)  (cons e env))
  (else              (apply (eval (car e) env) (eval (cadr e) env)))))

; apply takes a function and an argument to a value
(define (apply f x)
  (eval (cddr (car f)) (cons (list (cadr (car f)) x) (cdr f))))

; read and parse stdin, then evaluate:
(display (eval (read) '())) (newline)

Name: Anonymous 2011-08-20 10:49

Matt Might has made many other interesting posts, I suggest you to read his blog.

Name: Anonymous 2011-08-20 19:35

I'm not gonna pretend I got any of this
You're making me feel inadequate I had to fucking look up this word

Name: Anonymous 2011-08-21 20:31

(lambda =_=) <{I AM SO HIGH ON LAMBDAS RIGHT NOW...}

Name: Anonymous 2011-08-21 20:34

The Turing theorem: any useless toy language can be used to implement any other useless toy language.

Name: Anonymous 2011-08-22 8:54

>>5
For some people languages are tools (hammer, screwdriver...) For us, nerd kids, they are indeed *toys* (Lego, Meccano...)

Name: Anonymous 2011-08-22 13:14

>>1
implementing lambda in a language that already has lambda.

AMAZING!

Name: Anonymous 2011-08-22 13:26

BRILLIANT!

gay

Name: Anonymous 2011-08-22 14:16

>>7
That's not what he has done, they are not the same lambda.

You uncultured lowlife.

Name: Anonymous 2011-08-22 14:39

Implementing a programming language is an experience no programmer should go without; the process fosters a deep understanding of computation, and beside that, it's fun!

Name: Anonymous 2011-08-22 23:09

>>10
What your triying to say with that? Maybe you should confirm your assumptions?

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