graywolf on Nostr: If I want to create two lists from a single map, is there a nice pattern for it? Let ...
If I want to create two lists from a single map, is there a nice pattern for it?
Let us assume this as an example:
(let* ((sum+prod (map (λ (n)
(cons (+ 2 n) (* 2 n)))
(iota 10)))
(sum (map car sum+prod))
(prod (map cdr sum+prod)))
#t)
Is there an elegant way to re-write it using just one iteration?
#scheme #guile #lisp
Let us assume this as an example:
(let* ((sum+prod (map (λ (n)
(cons (+ 2 n) (* 2 n)))
(iota 10)))
(sum (map car sum+prod))
(prod (map cdr sum+prod)))
#t)
Is there an elegant way to re-write it using just one iteration?
#scheme #guile #lisp