RosettaCodeData/Task/Loops-For-with-a-specified-step/Scheme/loops-for-with-a-specified-step-4.ss
2023-07-01 13:44:08 -04:00

11 lines
326 B
Scheme

(define-syntax for-loop
(syntax-rules ()
((for-loop index start end step body ...)
(let ((evaluated-end end) (evaluated-step step))
(let loop ((i start))
(if (< i evaluated-end)
((lambda (index) body ... (loop (+ i evaluated-step))) i)))))))
(for-loop i 2 9 2
(display i)
(newline))