Summary
is a family of programming languages with fully parenthesized prefix notation. LISP: LISt Processor
Prefix Notation
LISP uses what is called a prefix notation, i.e. instead of writing 10+20 (this is called the infix notation) you have to write + 10 20.
S-expressions
In the usual parenthesized syntax of Lisp, an S-expression is classically defined[1] as
- an atom, or
-
- an expression of the form (x . y) where x and y are S-expressions.
Data-types
Two fundamental data types:
- Atoms
- Lists
e.g: (1 2 foo) is list with atoms 1, 2 and foo
Quote or “'” or apostrophe
Difference is applying function to symbol(quote) vs to value.
(atom? ‘turkey)
“atom?” is a function and “‘turkey” is the argument
(atom? 'turkey) ;; is same as
(atom? (quote turkey))
;; in the above s-expression
;; atom? gets evaluated to a function and "turkey" to a symbol not function.
;; so the function is applied to the symbol
(atom? turkey)
(atom? turkey)
;; atom? evaluates to function
;; turkey is variable, evaluating turkey gives the value that is bound to it.
;; function is applied to the value