1.1 The elements of programming
1.1.1 primitives expressions -> means of combination -> means of abstractions
465
(+ 1 2)
3
Expressions such as these, formed by delimiting a list of expressions within parentheses in order to denote procudure application, are called combinations. The leftmost element in the list is called the operator, and the remaining elements are called operands.
Placing the operator to the left of the operands is called prefix notation which has two advantages:
- It’s flexible, because it can accommodate precedures that may take an arbitrary number of arguments.
- A second advantage is that it extends in a straightforward way to allow combinations to be nested which means to have combinations whose elements are themselves combinations.
Following expressions demonstrate the second advantage of prefix notation:
(+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6))
This expression is confused for human, but it’s actually a very simple expression for lisp lisp interpretor. There is a easy way for humen to understand the lisp expression.
(+ (* 3
(+ (* 2 4)
(+ 3 5)))
(+ (- 10 7)
6))
This is called pretty-printing