4 ms·
Clearly this calls for a macro (define-syntax naive-for (syntax-rules () [(naive-for start end body ...) (let ([op (if (< start end)
by yoklov 14y ago
Clearly this calls for a macro
(define-syntax naive-for
(syntax-rules ()
[(naive-for start end body ...)
(let ([op (if (< start end) + -)])
(let loop ([s start] [e end])
(begin body ...)
(cond [(not (eq? s e))
(loop (op s 1) e)])))]))
(naive-for 1 -2
(displayln "Lambda? What lambda?"))
- codygman 14y agoThank you! I haven't gotten to macros yet, but I can see they are very straight-forward!