smart-2map-reduce ( 2map-reduce-quots -- quot ) (original) (raw)
smart-2map-reduce ( 2map-reduce-quots -- quot )
Vocabulary
combinators.smart
Inputs
2map-reduce-quots | a sequence |
---|
Outputs
None
Word description
A version of 2map-reduce that takes a sequence of { 2map-quot 2reduce-quot } pairs, returning the 2map-reduce result for each pair.
Definition
USING: assocs combinators generalizations kernel sequences ;
MACRO: smart-2map-reduce ( 2map-reduce-quots -- quot )
[ keys ] [ [ [ ] concat-as ] [ ] map-as ] bi dup length dup
[ [ [ [ first ] bi@ ] ] dip [ 2cleave ] curry compose ] 3dip
[ [ [ cleave-curry ] [ cleave-curry ] bi ] curry compose ]
dip [ spread* ] curry compose [ [ 2keep ] curry ] dip
[ 1 2each-from ] curry compose ;