Lecture overview -- Keyboard shortcut: 'u'  Previous page: Evaluation of parenthesized expressions -- Keyboard shortcut: 'p'  Next page: Equality in Scheme -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 2 - Page 8 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Arithmetic expressions

We will here point out that arithmetic expressions are written as fully parenthesized expressions with prefix notation

Scheme uses fully parenthesized arithmetic expressions with prefix notation

Using prefix notation the operator is given before the operands

Prefix notation stands as a contrast to infix and postfix notation. Infix notation is 'standard notation' in which the operand is found in between the operands.

Expression

Value

(+ 4 (* 5 6))
34
(define x 6)
(+ (* 5 x x) (* 4 x) 3)
207
(/ 21 5)
21/5
(/ 21.0 5)
4.2
(define (fak n)
  (if (= n 0) 1 (* n (fak (- n 1)))))

(fak 50)
30414093201713378043612608166064768
844377641568960512000000000000

Examples of arithmetic expressions. The prefix notation can be seen to the left, and the values of the expressions appear to the right.

There is no need for priorities - operator precedence rules - of operators in fully parenthesized expressions