Lecture overview -- Keyboard shortcut: 'u'  Previous page: Selection Control -- Keyboard shortcut: 'p'  Next page: Assignments in Functional Programs -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Simulation of other Paradigms and Continuations - slide 17 : 43

Iterative Control

Iterative control is handled by recursion in functional programming languages

Imperative

Functional - Scheme

int gcd(int small, int large){
  int rem; 
  while (small > 0){
    rem = large % small;
    large = small;
    small = rem;
  }
  return large;
}
(define (gcd small large)
  (if (> small 0)
      (gcd 
        (remainder large small)
        small)
      large))