(def reducecollect (sum list start) (if acons.list (let csum (sum start car.list) (cons csum (reducecollect sum cdr.list csum))))) (def zip args (when (all acons args) (cons (map car args) (apply zip (map cdr args))))) (mac biased-choice choices (with (ranges (reducecollect + (map car pair.choices) 0) items (map cadr pair.choices) random (uniq)) `(let ,random (* (rand) ,last.ranges) (if ,@(apply join (zip (map [list '< random _] ranges) items))))))
(def zip args (apply map list args))
-----
(def unzip (xs (o n 2)) (apply map list (tuples xs n))) arc> (unzip '(a b c d e f) 3) ((a d) (b e) (c f))