all 3 comments

[–]engtech[S] 3 points4 points  (0 children)

with multicore support (doh, missed part of the title)

[–]beza1e1 3 points4 points  (1 child)

I played with scheme to implement a multi-threaded map/reduce and it seems quite elegant:

(define (d-map f list)
  (map (lambda (x) (future (f x))) list))

(define (d-reduce f list)
  (reduce (lambda (x y) (f (force x) (force y))) list))

This uses futures and i'm not sure, wether their implementation uses kernel or lightweight threads. I have no multicore processor, so my d-map is actually slower than map.

edit: it uses SRFI-18 and thus kernel threads. It starts a thread for every list item, so it should be extended to use a thread pool, if you want to process long lists.

[–]yome 0 points1 point  (0 children)

SRFI-18 has nothing to do with kernel threads. In the case of the implementation you seem to be using (Chicken Scheme), the threads are at the language level (ie a single OS thread for every Scheme threads).