Closures/Value capture: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 728: | Line 728: | ||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
<lang scheme> |
<lang scheme>;;; Collecting lambdas in a tail-recursive function. |
||
(define (build-list-of-functions n i list) |
|||
(if (< i n) |
(if (< i n) |
||
(build-list-of-functions n (+ i 1) (cons (lambda () (* (- n i) (- n i))) list)) |
(build-list-of-functions n (+ i 1) (cons (lambda () (* (- n i) (- n i))) list)) |