Lecture overview -- Keyboard shortcut: 'u'  Previous page: Assignments in Functional Programs -- Keyboard shortcut: 'p'  Next page: Object Mutation -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 3 - Page 19 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
State in Functional Programs

State transitioning - where a set of variables are updated simultaneously - can be dealt with by parameter passing - typically in a tail recursive function

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))

We illustrate the handling of state transitioning