; threaded-map : (X -> Y) * (listof X) -> (listof Y)
; maps the given function over the given list with each computation
; done in parallel
(define (threaded-map f l)
(let ((cs (map (lambda (x) (make-channel)) l)))
(for-each (lambda (x c) (thread (lambda () (channel-put c (f x))))) l cs)
(map channel-get cs)))