combinators.smart: Add cleave>sequence.

db4
Doug Coleman 2012-09-19 14:58:55 -07:00
parent d196f8f141
commit cda2e4d7da
2 changed files with 8 additions and 0 deletions

View File

@ -90,3 +90,8 @@ IN: combinators.smart.tests
{ 1 1 1 } [ 1 3 [ ] smart-with times ] unit-test
{ "BCD" } [ 1 "ABC" [ + ] smart-with map ] unit-test
{ H{ { 1 2 } } } [ 1 H{ { 1 2 } { 3 4 } } [ drop = ] smart-with assoc-filter ] unit-test
: test-cleave>sequence ( obj -- seq ) { [ 1 + ] [ sq ] [ 1 - ] } V{ } cleave>sequence ;
\ test-cleave>sequence def>> must-infer
{ V{ 34 1089 32 } } [ 33 test-cleave>sequence ] unit-test

View File

@ -70,6 +70,9 @@ M: object infer-known* drop f ;
: cleave>array ( x seq -- array )
'[ _ cleave ] output>array ; inline
: cleave>sequence ( x seq exemplar -- array )
[ '[ _ cleave ] ] dip output>sequence ; inline
: input<sequence ( seq quot -- )
[ inputs firstn ] [ call ] bi ; inline