|
|
|
|
|
by namekuseijin
5721 days ago
|
|
that's bad assembly-style pseudo-code and thinking. Lisp favors higher-level, functional pseudo-code that readily runs as is! like in scheme:
(write
(let for ((i 0) (s 0))
(if (> i 100) s
(for (+ 1 i) (+ i s))))) why would you care for those a, b, or s variables in the first place when all you want is the sum? The above expression writes the sum as computed by a recursive approach using lexical bindings. you may of course abstract it away into a function:
(define (for from to doit result)
(if (> from to) result
(for (+ 1 from) to doit (doit from result)))) and use it:
(write
(let ((a 0)
(b 100))
(for a b + 0))) I didn't even need macros yet! |
|