combinators.smart: add nullary combinator and some tests
parent
2557ce1010
commit
8e90b92da2
|
@ -47,3 +47,9 @@ IN: combinators.smart.tests
|
||||||
[ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test
|
[ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] unit-test
|
||||||
|
|
||||||
[ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test
|
[ 14 ] [ [ 1 2 3 ] [ sq ] [ + ] map-reduce-outputs ] unit-test
|
||||||
|
|
||||||
|
{ 2 3 } [ [ + ] preserving ] must-infer-as
|
||||||
|
|
||||||
|
{ 2 0 } [ [ + ] nullary ] must-infer-as
|
||||||
|
|
||||||
|
{ 2 2 } [ [ [ + ] nullary ] preserving ] must-infer-as
|
||||||
|
|
|
@ -46,5 +46,8 @@ MACRO: append-outputs ( quot -- seq )
|
||||||
MACRO: preserving ( quot -- )
|
MACRO: preserving ( quot -- )
|
||||||
[ infer in>> length ] keep '[ _ ndup @ ] ;
|
[ infer in>> length ] keep '[ _ ndup @ ] ;
|
||||||
|
|
||||||
|
MACRO: nullary ( quot -- quot' )
|
||||||
|
dup infer out>> length '[ @ _ ndrop ] ;
|
||||||
|
|
||||||
MACRO: smart-if ( pred true false -- )
|
MACRO: smart-if ( pred true false -- )
|
||||||
'[ _ preserving _ _ if ] ; inline
|
'[ _ preserving _ _ if ] ; inline
|
||||||
|
|
Loading…
Reference in New Issue