; http://cap-lore.com/code/Scheme/Do.html (let* ( (Do (lambda (n p) (let Do ((n n)) (if (> n 0) (let ((u (- n 1))) (p u) (Do u)) '())))) (DoL (lambda (n p) (let l ((v '())(n (- n 1))) (if (< n 0) v (l (cons (p n) v)(- n 1)))))) (DoV (lambda (n p) (let ((v (make-vector n))) (Do n (lambda (j) (vector-set! v j (p j)))) v))) (DoF (lambda (n p i) (let D ((n n) (i i)) (if (= n 0) i (D (- n 1) (p (- n 1) i))))))) (lambda (sy) (cdr (assq sy (list (cons 'Do Do) (cons 'DoL DoL)(cons 'DoV DoV)(cons 'DoF DoF)))))) ; Tests: (let ((D (fileVal "Do"))) (list ((D 'Do) 4 (lambda (j) (write j))) ; => 3210 ((D 'DoV) 5 (lambda (j) (+ j 3))) ; => #5(3 4 5 6 7) ((D 'DoL) 7 (lambda (j) (* 10 j))) ; => (0 10 20 30 40 50 60) ((D 'DoF) 100 + 100))) ; => 5050