[racket] Future function in Racket
An hour ago, Mohammad Mustaqeem wrote:
> Hello,
> I want to verify that "is future executes the thunk in parallel"?
> For that, I need an example that show the difference between execution
> time of the using future and without it.
> Please, give me an example verifies that "future executes the
> thunk in parallel"
-> (let ([N 6])
(define results (make-vector (add1 N) 0))
(for ([i 100000])
(define s 0)
(define fs (for/list ([i N]) (future (λ () (set! s (add1 s))))))
(for-each touch fs)
(vector-set! results s (add1 (vector-ref results s))))
results)
'#(0 0 3 0 2 452 99543)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!