What does this xkcd code do?

Posted by cobbal on Stack Overflow See other posts from Stack Overflow or by cobbal
Published on 2009-10-26T17:25:03Z Indexed on 2012/07/08 3:16 UTC
Read the original article Hit count: 391

Filed under:
|

On the xkcd site today, the following appeared as a joke in a <script language="scheme"> tag

so what does the following code do / represent?

(define
  (eval exp env)
  (cond ((self-evaluating? exp) exp)
    ((variable? exp)
      (lookup-variable-value exp env))
    ((quoted? exp)
      (text-of-quotation exp))
    ((assignment? exp)
      (eval-assignment exp env))
    ((definition? exp)
      (eval-definition exp env))
    ((if? exp)
      (eval-if exp env))
    ((lambda? exp)
      (make-procedure
        (lambda-parameters exp)
        (lambda-body exp)  env))
    ((begin? exp)
      (eval-sequence (begin-actions exp) env))
    ((cond? exp)
      (eval (cond->if exp) env))
    ((application? exp)
      (apply (eval (operator exp) env)
        (list-of-values (operands exp) env)))
    (else  (error "Common Lisp or Netscape Navigator 4.0+ Required" exp))))

© Stack Overflow or respective owner

Related posts about lisp

Related posts about Scheme