Sujet : Re: Why don't people like lisp?
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.schemeDate : 09. Jul 2025, 20:37:43
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <104mge5$d3rl$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
David Steuber wrote:
Try doing this in C++, Python, or whatever:
(do ((a 1 b) (b 1 (+ a b)))
(nil a)
(print a))
That ought to be:
(do ((a 0 b) (b 1 (+ a b)))
(nil)
(print b))
In Gauche Scheme using do_:
(do_ ((a 0 b) (b 1 (+ a b)))
()
(print b))
Another way:
(do_ (: a 0 b b 1 (+ a b))
()
(print b))
Given:
(define-syntax do_-aux
(syntax-rules ( <> @ :in :collect :below :to : )
[ (do_-aux ((x what <>) more ...) (seen ...) stuff ...)
(do_-aux (more ...) (seen ... (x what what)) stuff ...) ]
[ (do_-aux ((x a :below b) more ...) seen lets (bool z ...) stuff ...)
(do_-aux ((top b)
(x a (+ x 1)) more ...) seen lets
((or (>= x top) bool) z ...) stuff ...) ]
[ (do_-aux ((x a :to b) more ...) stuff ...)
(do_-aux ((x a :below (+ 1 b)) more ...) stuff ...) ]
[ (do_-aux ((x :in seq) more ...) seen (lets ...) (bool z ...) stuff ...)
(do_-aux ((x (and (pair? the-list) (car the-list)) <>) more ...)
seen
(lets ... (the-list seq))
((or (null? the-list) (begin (pop! the-list) #f) bool) z ...)
stuff ...) ]
[ (do_-aux ((accum :collect x) more ...) stuff ...)
(do_-aux ((accum '() (cons x accum)) more ...) stuff ...) ]
[ (do_-aux (: v init update more ...) (seen ...) stuff ...)
(do_-aux (: more ...) (seen ... (v init update)) stuff ...) ]
[ (do_-aux (:) stuff ...)
(do_-aux () stuff ...) ]
[ (do_-aux (spec more ...) (seen ...) stuff ...)
(do_-aux (more ...) (seen ... spec) stuff ...) ]
[ (do_-aux () seen lets (bool y ... @ result) stuff ...)
(do_-aux () seen lets (bool y ... (reverse result)) stuff ...) ]
[ (do_-aux () seen (lets ...) more ...)
(let (lets ...)
(do seen more ...))
] ))
(define-syntax do_
(syntax-rules ()
[ (do_ specs () more ...)
(do_ specs (#f) more ...) ]
[ (do_ specs more ...)
(do_-aux specs () () more ...) ] ))