Lisp
Lisp
Introduction
ACSL LISP is a pretty simple topic. Like assembly the main thing is simply that you know the language. ACSL LISP is somewhat dierent from modern Common Lisp. The keywords are all-caps and the syntax more verbose, and the language itself is greatly simplied. Just learn the functions and youll be ne.
Lisp in general has a uniform syntax. It is composed of S-expressions, parenthesized lists built out of smaller lists or atoms. This simplicity made it very easy to implement in the past. Lisp is one of the oldest programming language (not counting assembly and machine code), second only to Fortran. A couple of unique aspects of Lisp are the congruence between code and data. Lisp code corresponds almost exactly with the internal representation used by the compiler or interpreter. Everything is a list. Many assert this makes it useful for metaprogramming and the like. Unsurprisingly, Lisp was the rst language to use a self-hosting compiler.
Syntax
As mentioned before, Lisp code is just a series of S-expressions. The rst element in a list represents a function and the rest represents its arguments. CAR and CDR are two functions unique to Lisp. The bizarre names are a holdover from some ancient computer the original Lisp ran on. They refer to the head and tail of a list, respectively. Quoting ( (1 2 3)) prevents
evaluation of the list, signaling that you want a simple list of atoms. Function denition is slightly inconsistent with function application. Heres an example of a user-dened function: (DEF F (A B) (PLUS A (MULT 2 B ) ) ) (DEF SECOND (LST) (CAR (CDR LST ) ) ) (F 1 2 ) ; ; 5 (SECOND ( 1 2 3 4 5 ) ) ; ; 2