Lecture overview -- Keyboard shortcut: 'u'  Previous page: Practical implications -- Keyboard shortcut: 'p'  Next page: Lazy evaluation -- 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 5 - Page 18 : 26
Functional Programming in Scheme
The Order of Evaluation
Conditionals and sequential boolean operators

There are functional language constructs - special forms - for which applicative order reduction would not make sense

  • (if b x y)

    • Depending on the value of b, either x or y are evaluated

    • It would often be harmful to evaluate both x and y before the selection

      • (define (fak n) (if (= n 0) 1 (* n (fak (- n 1)))))

  • (and x y z)

    • and evaluates its parameter from left to right

    • In case x is false, there is no need to evaluate y and z

    • Often, it would be harmful to evaluate y and z

      • (and (not (= y 0)) (even? (quotient x y)))