combinators.extras: adding cleave-array.

db4
John Benediktsson 2013-03-24 19:34:39 -07:00
parent 6c0bb0f343
commit 31d6fb178a
2 changed files with 7 additions and 1 deletions

View File

@ -21,3 +21,5 @@ IN: combinators.extras.tests
} cond-case
] map
] unit-test
{ { 1 2 3 } } [ 1 { [ ] [ 1 + ] [ 2 + ] } cleave-array ] unit-test

View File

@ -1,6 +1,7 @@
! Copyright (C) 2013 Doug Coleman, John Benediktsson.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays combinators kernel macros quotations sequences ;
USING: arrays combinators fry kernel macros quotations
sequences sequences.generalizations ;
IN: combinators.extras
: once ( quot -- ) call ; inline
@ -14,3 +15,6 @@ MACRO: cond-case ( assoc -- )
[ second [ drop ] prepose ] bi 2array
] when
] map [ cond ] curry ;
MACRO: cleave-array ( quots -- )
[ '[ _ cleave ] ] [ length '[ _ narray ] ] bi compose ;