3map-reduce ( ..a seq1 seq2 seq3 map-quot: ( ..a elt1 elt2 elt3 -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result )


Vocabulary
sequences.extras

Inputs
seq1a sequence
seq2a sequence
seq3a sequence
map-quotan object
reduce-quotan object


Outputs
resultan object


Word description
Applies map-quot to each triple of elements in turn, yielding new elements which are collected into a new sequence having the same class as seq1. The resultant sequence is then reduced with reduce-quot.

Definition


: 3map-reduce
( ..a seq1 seq2 seq3 map-quot: ( ..a elt1 elt2 elt3 -- ..b intermediate ) reduce-quot: ( ..b prev intermediate -- ..a next ) -- ..a result )
[ [ [ [ first ] tri@ ] 3keep ] dip [ 3dip ] keep ] dip
compose 1 3each-from ; inline