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 together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Simulation of other Paradigms and Continuations - slide 19 : 43

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


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)
        (remainder large small)