document and fix stack effect for 2cleave, 3cleave

db4
Doug Coleman 2008-09-05 17:27:10 -05:00
parent 5ed87d4d34
commit dfeb610555
2 changed files with 16 additions and 2 deletions

View File

@ -16,6 +16,10 @@ $nl
{ $subsection while }
"Generalization of " { $link bi } " and " { $link tri } ":"
{ $subsection cleave }
"Generalization of " { $link 2bi } " and " { $link 2tri } ":"
{ $subsection 2cleave }
"Generalization of " { $link 3bi } " and " { $link 3tri } ":"
{ $subsection 3cleave }
"Generalization of " { $link bi* } " and " { $link tri* } ":"
{ $subsection spread }
"Two combinators which abstract out nested chains of " { $link if } ":"
@ -50,6 +54,16 @@ HELP: cleave
}
} ;
HELP: 2cleave
{ $values { "x" object } { "y" object }
{ "seq" "a sequence of quotations with stack effect " { $snippet "( x y -- ... )" } } }
{ $description "Applies each quotation to the two objects in turn." } ;
HELP: 3cleave
{ $values { "x" object } { "y" object } { "z" object }
{ "seq" "a sequence of quotations with stack effect " { $snippet "( x y z -- ... )" } } }
{ $description "Applies each quotation to the three objects in turn." } ;
{ bi tri cleave } related-words
HELP: spread

View File

@ -13,14 +13,14 @@ IN: combinators
[ [ keep ] curry ] map concat [ drop ] append [ ] like ;
! 2cleave
: 2cleave ( x seq -- )
: 2cleave ( x y seq -- )
[ 2keep ] each 2drop ;
: 2cleave>quot ( seq -- quot )
[ [ 2keep ] curry ] map concat [ 2drop ] append [ ] like ;
! 3cleave
: 3cleave ( x seq -- )
: 3cleave ( x y z seq -- )
[ 3keep ] each 3drop ;
: 3cleave>quot ( seq -- quot )