combinators.cleave: add general cleave macro

db4
Eduardo Cavazos 2008-02-23 15:51:10 -06:00
parent 00333096e1
commit 73ba7221af
1 changed files with 17 additions and 3 deletions

View File

@ -1,5 +1,5 @@
USING: kernel ;
USING: kernel sequences macros ;
IN: combinators.cleave
@ -19,6 +19,22 @@ IN: combinators.cleave
: 2bi ( obj obj quot quot -- val val ) >r 2keep r> call ; inline
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! General cleave
MACRO: cleave ( seq -- )
dup
[ drop [ dup ] ] map concat
swap
dup
[ drop [ >r ] ] map concat
swap
[ [ r> ] append ] map concat
3append
[ drop ]
append ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! The spread family
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -35,8 +51,6 @@ IN: combinators.cleave
! General spread
USING: sequences macros ;
MACRO: spread ( seq -- )
dup
[ drop [ >r ] ] map concat