concurrency.combinators: adding parallel-assoc-map.
parent
13294b49ef
commit
7c9e0f3017
|
@ -53,3 +53,9 @@ IN: concurrency.combinators.tests
|
|||
[ number>string ] 3 parallel-napply
|
||||
{ [ "a" append ] [ "b" append ] [ "c" append ] } parallel-spread
|
||||
] unit-test
|
||||
|
||||
{ H{ { 0 4 } { 2 6 } { 4 8 } } } [
|
||||
H{ { 1 2 } { 3 4 } { 5 6 } } [
|
||||
[ 1 - ] [ 2 + ] bi*
|
||||
] parallel-assoc-map
|
||||
] unit-test
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays combinators concurrency.count-downs
|
||||
USING: arrays assocs combinators concurrency.count-downs
|
||||
concurrency.futures fry generalizations kernel macros sequences
|
||||
sequences.private sequences.product ;
|
||||
IN: concurrency.combinators
|
||||
|
@ -43,6 +43,14 @@ PRIVATE>
|
|||
: parallel-map ( seq quot: ( elt -- newelt ) -- newseq )
|
||||
[future] map future-values ; inline
|
||||
|
||||
: parallel-assoc-map-as ( assoc quot: ( key value -- newkey newvalue ) exemplar -- newassoc )
|
||||
[
|
||||
[ 2array ] compose '[ _ 2curry future ] { } assoc>map future-values
|
||||
] dip assoc-like ;
|
||||
|
||||
: parallel-assoc-map ( assoc quot: ( key value -- newkey newvalue ) -- newassoc )
|
||||
over parallel-assoc-map-as ;
|
||||
|
||||
: 2parallel-map ( seq1 seq2 quot: ( elt1 elt2 -- newelt ) -- newseq )
|
||||
'[ _ 2curry future ] 2map future-values ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue