]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.smart: Add cleave>sequence.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 19 Sep 2012 21:58:55 +0000 (14:58 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 19 Sep 2012 22:44:20 +0000 (15:44 -0700)
basis/combinators/smart/smart-tests.factor
basis/combinators/smart/smart.factor

index fbe7715eb7352e3cc120b56e87a8e9ac90bdef92..4b47094c2d54ce0b38ec863f9c2df4ae4bc2c880 100644 (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
index 81528c1823b750bc345290bc17c55ecd67eeb5c2..5b37606dc9a7492ea3f604564fa3ee3a0261dce5 100644 (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