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