www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 6195397e673a178b033b2b6c3a9e6bfe78638697
parent 93346c5a2896f208c370b36bd0a83b5b6328e914
Author: Andreas Olsson <photoguy.apo@gmail.com>
Date:   Thu, 22 Dec 2016 15:17:07 +0100

Add files via upload
Diffstat:
Apmap.rkt | 34++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+), 0 deletions(-)

diff --git a/pmap.rkt b/pmap.rkt @@ -0,0 +1,33 @@ +#lang racket + +(require racket/future) +(require racket/future + future-visualizer) + +(define f (format "~a" (futures-enabled?))) +(println (string-append "futures enabled: " f)) + +(define pc (format "~a" (processor-count))) +(println (string-append "processor-count: " pc)) + + +(provide pmap) +(provide pmapTwo) + +(define (pmap func alist) ; Sort of pmap + (let* ([f (for/list ([a alist]) (future (lambda () (func a ))) )]) + (for/list ([i f]) (touch i))) + ) + +;(visualize-futures ; If function isnt heavy enuf you will get an error, try comment out! +(pmap (lambda (x)(car x)) '((a b)(c d)(e f))) +;) + +(define (pmapTwo func alist blist) ; Sort of pmap + (let* ([f (for/list ([a alist][b blist]) (future (lambda () (func a b))) )]) + (for/list ([i f]) (touch i))) + ) + +;(visualize-futures ; If function isnt heavy enuf you will get an error, try comment out! +(pmapTwo (lambda (x y) (* x y)) '(1 2 3 4 5) '(1 2 3 4 5 6)) +;) +\ No newline at end of file