Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this xkcd code do?

Tags:

lisp

scheme

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))))
like image 632
cobbal Avatar asked Oct 26 '09 17:10

cobbal


People also ask

What is Xkcd stand for?

What does XKCD stand for? It's not actually an acronym. It's just a word with no phonetic pronunciation -- a treasured and carefully-guarded point in the space of four-character strings.

How many Xkcd are there?

xkcd: 1000 Comics. [[1000 characters, numerous of which have appeared previously in other comics, are arranged to create the number "1000".

Why is Xkcd named?

According to Munroe, the comic's name has no particular significance and is simply a four-letter word without a phonetic pronunciation, something he describes as "a treasured and carefully guarded point in the space of four-character strings." In January 2006, the comic was split off into its own website, created in ...

Who is the XKCD guy?

Randall Patrick Munroe (born October 17, 1984) is an American cartoonist, author, and engineer best known as the creator of the webcomic xkcd. Munroe has worked full-time on the comic since late 2006.


1 Answers

It's essentially a simple interpreter, if you assume that all the requisite methods are filled in.

like image 53
Oliver N. Avatar answered Sep 28 '22 09:09

Oliver N.