The original LISP

Here is an implementation of the Original LISP as documented in

                                  March 4, 1959

    Artificial Intelligence Project--RLE and MIT Computation Center

                           Memo 8

    RECURSIVE FUNCTIONS OF SYMBOLIC EXPRESSIONS AND THEIR COMPUTATION

                         BY MACHINE

                       by J. McCarthy
   

The only symbols predefined are: DEFINE, LAMBDA, LABEL, COND, COMBINE, FIRST, REST, NULL, ATOM, EQ, NIL, T, and QUOTE.

The file aim-8.lisp contains an implementation in Common-Lisp.

The file aim-8.aim-8 contains an implementation in AIM-8 LISP.

The file examples.aim-8 contains the other examples given in AIM-8: differential and turing machine.

(It should be noted that "compiler" occurs 4 times in this Memo, while "interpreter" doesn't appears.)

For more information about Lisp history, see the Computer History Museum, History of Lisp

Exemple

% /usr/local/bin/clisp -norc -ansi 
  i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  I I I I I I I      8     8   8           8     8     o  8    8
  I  \ `+' /  I      8         8           8     8        8    8
   \  `-+-'  /       8         8           8      ooooo   8oooo
    `-__|__-'        8         8           8           8  8
        |            8     o   8           8     o     8  8
  ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2006

[1]> (load (compile-file "aim-8.lisp"))
;; Compiling file /local/users/pjb/src/public/small-cl-pgms/aim-8/aim-8.lisp ...
;; Wrote file /local/users/pjb/src/public/small-cl-pgms/aim-8/aim-8.fas
0 errors, 0 warnings
;; Loading file /local/users/pjb/src/public/small-cl-pgms/aim-8/aim-8.fas ...
;; Loaded file /local/users/pjb/src/public/small-cl-pgms/aim-8/aim-8.fas
T
[2]> (aim-8:repl)
You've got:
    LAMBDA LABEL
    COND AND OR NOT  COMBINE FIRST REST
    NULL ATOM EQ NIL T QUOTE
Extensions:
    DEFINE RELOAD DUMP-ENVIRONMENT LOAD
    QUIT
AIM-8> (define maplist
           (lambda (x f)
             (cond ((null x) nil)
                   (t        (combine (f x) (maplist (rest x) f))))))
MAPLIST
AIM-8> (define diff
           (lambda (y x)
             (cond
               ((atom y)
                (cond ((eq y x) (quote one))
                      (t (quote zero))))
               ((eq (first y) (quote plus))
                (combine (quote plus)
                         (maplist (rest y) (lambda (a) (diff (first a) x)))))
               ((eq (first y) (quote times))
                (combine (quote plus)
                         (maplist
                          (rest y)
                          (lambda (a) (combine
                                  (quote times)
                                  (maplist
                                   (rest y)
                                   (lambda (w) (cond
                                            ((not (eq a w)) (first w))
                                            (t (diff (first w) x))
                                            )))))))))))
DIFF
AIM-8> (diff (quote (plus (times a x) b)) (quote x))
(PLUS (PLUS (TIMES ZERO X) (TIMES A ONE)) ZERO)
AIM-8> (diff (quote (plus (times a x x) (times b x) c)) (quote x))
(PLUS (PLUS (TIMES ZERO X X) (TIMES A ONE X) (TIMES A X ONE))
 (PLUS (TIMES ZERO X) (TIMES B ONE)) ZERO)

;; Beware, AIM-8 is defined with substitution evaluation.
;; Therefore, for each occurence of a variable, the whole expression
;; bound to this variable is evaluated again.  This gives surprizing
;; results for procedures with side-effects like PRINT and READ.
;; Moreover, this has the effect of giving exponential complexities very easily.

AIM-8> ((lambda (x) (combine x (combine x nil))) (print (quote a)))

A
A (A A)
AIM-8> (quit)
GOOD BYE
NIL
[3]> (quit)
Bye.
%

  

| Mirror on informatimago.com | Mirror on free.fr |
Valid HTML 4.01!