Oddbean new post about | logout
 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