combinators.smart: add nullary combinator and some tests

db4
Slava Pestov 2009-11-09 00:53:58 -06:00
parent 2557ce1010
commit 8e90b92da2
2 changed files with 9 additions and 0 deletions

View File

@ -47,3 +47,9 @@ IN: combinators.smart.tests
[ { { 1 2 } { 3 4 } } ] [ nested-smart-combo-test ] 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

View File

@ -46,5 +46,8 @@ MACRO: append-outputs ( quot -- seq )
MACRO: preserving ( quot -- )
[ infer in>> length ] keep '[ _ ndup @ ] ;
MACRO: nullary ( quot -- quot' )
dup infer out>> length '[ @ _ ndrop ] ;
MACRO: smart-if ( pred true false -- )
'[ _ preserving _ _ if ] ; inline