diff --git a/basis/combinators/smart/smart-tests.factor b/basis/combinators/smart/smart-tests.factor index 69a3a821e5..1cca697dde 100644 --- a/basis/combinators/smart/smart-tests.factor +++ b/basis/combinators/smart/smart-tests.factor @@ -44,4 +44,6 @@ IN: combinators.smart.tests \ nested-smart-combo-test must-infer -[ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test \ No newline at end of file +[ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test + +[ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test \ No newline at end of file diff --git a/basis/combinators/smart/smart.factor b/basis/combinators/smart/smart.factor index e93d84e394..e7bdd75ced 100644 --- a/basis/combinators/smart/smart.factor +++ b/basis/combinators/smart/smart.factor @@ -21,6 +21,12 @@ MACRO: reduce-outputs ( quot operation -- newquot ) : sum-outputs ( quot -- n ) [ + ] reduce-outputs ; inline +MACRO: map-reduce-outputs ( quot mapper reducer -- newquot ) + [ dup infer out>> ] 2dip + [ swap '[ _ _ napply ] ] + [ [ 1 [-] ] dip n*quot ] bi-curry* bi + '[ @ @ @ ] ; + MACRO: append-outputs-as ( quot exemplar -- newquot ) [ dup infer out>> ] dip '[ @ _ _ nappend-as ] ;