Sujet : Re: walk through list and add all n'th item
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 19. Jul 2024, 05:17:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v7clse$2qjma$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Wow: loop macro rulez, somehow..
just one correction:
(loop for (a b c d) on (list 1 2 3 4 5 6 7 8) by #'cddddr
sum a into a-sum
sum b into b-sum
sum c into c-sum
sum d into d-sum
finally (return (list a-sum b-sum c-sum d-sum)))
Yeah, i might consider this code as beautiful
olivier
Gauche Scheme
(use gauche.lazy)
(use util.match)
(define data (lrange 1 57))
(match (lslices data 4)
[((a b c d) ...)
(map (cut fold + 0 <>)
(list a b c d))])
(378 392 406 420)