Friday, February 18, 2011

An early LISP program (circa Feb. 1960)

       TST M948-371-P. FOX-EXERCISE 1
   ((ATOM,L), (CONS,L,NIL))
))))) ()
COLLAPSE ((((A,B),((C))),((D,(E,F)),(G),((H))))) ()
COLLAPSE ((A,(B,(C,(D,(E))),F,(G,(H,J))))) ()
COLLAPSE ((((((A),B),C),D),E)) ()
        FIN M948-371-P. FOX-EXERCISE 1
  1. This example and the quotes below were taken from the LISP I manual by Phyllis Fox. The output from the program contains these two lines:
    THE TIME IS NOW 2/16 1139.5
    so we can date the sample run.
  2. Each line above was punched on a separate card.
  3. The TST (or SET) card indicates the beginning of the program. The FIN card indicates the end.
  4. This is followed by triplets of the form <function>, <argument-list>, <environment>. Instead of read, eval, print, the main loop is more like read, read, read, apply, print.
  5. The STOP card has lots of extra close parens in order to keep the reader from consuming the entire card deck if the programmer didn't correctly close all the parens.
  6. — “The read program reads until it finds the correct number of final parenthesis.
  7. S-expressions were originally supposed to have commas between the elements. The LISP I manual explains: “The commas in writing S-expressions may be omitted. This is an accident.” The author of the reader took a shortcut and treated whitespace as commas. “The current version of the read program interprets a blank (space) as a comma, so that no blanks are allowed within atomic symbols.
  8. LISP II will be able to handle both integers and floating point numbers, but in LISP I integers are not allowed. ... Numbers are brought into a LISP program by being defined within S-expressions, and they must always be quoted. For example, the following expression is correct, (SUM,(QUOTE,0.6),X)
  9. Values of compiled functions are computed about 60 times faster than the S-expressions for the functions could be interpreted... After a function has been compiled, it can be used as if it had been defined, but of course it will run much faster than it would have as an interpreted expression.
Post a Comment