chickadee » transducers » collect-unzip

collect-unzip left-collector right-collectorprocedure

This collector will accept individual values as pairs (as though calling (cons l r)), and collect the left and right sides into either of the left and right collectors passed into the procedure, respectively.

 
(import transducers test)

(let ((left-side (list 1 2 3))
      (right-side (list 4 5 6)))
 (test "zipping and then unzipping produces the same lists"
  (cons left-side right-side)
  (transduce list-fold
   (zip-list right-side)
   (collect-unzip (collect-list) (collect-list))
   left-side)))