db4
Slava Pestov 2008-10-20 01:58:17 -05:00
parent b9df6d89e3
commit f721105993
2 changed files with 11 additions and 0 deletions

View File

@ -621,6 +621,14 @@ HELP: 2dip
{ $code "[ foo bar ] 2dip" } { $code "[ foo bar ] 2dip" }
} ; } ;
HELP: 3dip
{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quot" quotation } }
{ $description "Calls " { $snippet "quot" } " with " { $snippet "obj1" } ", " { $snippet "obj2" } " and " { $snippet "obj3" } " hidden on the retain stack." }
{ $notes "The following are equivalent:"
{ $code ">r >r >r foo bar r> r> r>" }
{ $code "[ foo bar ] 3dip" }
} ;
HELP: while HELP: while
{ $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } } { $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } }
{ $description "Repeatedly calls " { $snippet "pred" } ". If it yields " { $link f } ", iteration stops, otherwise " { $snippet "body" } " is called. After iteration stops, " { $snippet "tail" } " is called." } { $description "Repeatedly calls " { $snippet "pred" } ". If it yields " { $link f } ", iteration stops, otherwise " { $snippet "body" } " is called. After iteration stops, " { $snippet "tail" } " is called." }
@ -815,6 +823,7 @@ ARTICLE: "slip-keep-combinators" "The dip, slip and keep combinators"
"The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:" "The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:"
{ $subsection dip } { $subsection dip }
{ $subsection 2dip } { $subsection 2dip }
{ $subsection 3dip }
"The slip combinators invoke a quotation further down on the stack. They are most useful for implementing other combinators:" "The slip combinators invoke a quotation further down on the stack. They are most useful for implementing other combinators:"
{ $subsection slip } { $subsection slip }
{ $subsection 2slip } { $subsection 2slip }

View File

@ -59,6 +59,8 @@ DEFER: if
: 2dip ( obj1 obj2 quot -- obj1 obj2 ) -rot 2slip ; inline : 2dip ( obj1 obj2 quot -- obj1 obj2 ) -rot 2slip ; inline
: 3dip ( obj1 obj2 obj3 quot -- obj1 obj2 obj3 ) -roll 3slip ; inline
! Keepers ! Keepers
: keep ( x quot -- x ) over slip ; inline : keep ( x quot -- x ) over slip ; inline