lambda-expressions/lambda3.scm - Same in Scheme - where this kind of stuff works out of the box. | Lecture 3 - slide 2 : 27 Program 6 |
; Shows a Scheme counterpart to lambda3.cc. Gives same output as lambda4.cc. (define (f seed0) (let ((seed seed0)) (lambda (i) (set! seed (+ 1 seed)) (+ i seed)))) (define g (f 5)) (map (lambda (a) (g a)) (list 1 2 3 4 5)) ; (7 9 11 13 15)