{ $description "Adds the top " { $snippet "n" } " stack values." } ;
HELP:npick
{ $values { "n"integer } }
{ $description "A generalization of " { $link dup } ", "
{ $link over } " and " { $link pick } " that can work "
"for any stack depth. The nth item down the stack will be copied and "
"placed on the top of the stack."
}
{ $examples
{ $example
"USING: kernel generalizations prettyprint"
"sequences.generalizations ;"
""
"1 2 3 4 4 npick 5 narray ."
"{ 1 2 3 4 1 }"
}
"Some core words expressed in terms of " { $link npick } ":"
{ $table
{ { $link dup } { $snippet "1 npick" } }
{ { $link over } { $snippet "2 npick" } }
{ { $link pick } { $snippet "3 npick" } }
}
} ;
HELP:ndup
{ $values { "n"integer } }
{ $description "A generalization of " { $link dup } ", "
{ $link 2dup } " and " { $link 3dup } " that can work "
"for any number of items. The n topmost items on the stack will be copied and "
"placed on the top of the stack."
}
{ $examples
{ $example
"USING: prettyprint generalizations kernel"
"sequences.generalizations ;"
""
"1 2 3 4 4 ndup 8 narray ."
"{ 1 2 3 4 1 2 3 4 }"
}
"Some core words expressed in terms of " { $link ndup } ":"
{ $table
{ { $link dup } { $snippet "1 ndup" } }
{ { $link 2dup } { $snippet "2 ndup" } }
{ { $link 3dup } { $snippet "3 ndup" } }
}
} ;
HELP:dupn
{ $values { "n"integer } }
{ $description "Calls " { $link dup } " enough times that " { $snippet "n" } " references to the element at the top of the stack before " { $snippet "dupn" } " is called are on the top of the stack." }
{ $notes { $snippet "2 dupn" } " is equivalent to " { $link dup } ". " { $snippet "1 dupn" } " is a no-op. " { $snippet "0 dupn" } " is equivalent to " { $link drop } "." } ;
HELP:nnip
{ $values { "n"integer } }
{ $description "A generalization of " { $link nip } " and " { $link 2nip }
{ $description "A generalization of " { $link spread } " that can work for any quotation arity."
} ;
HELP:cleave*
{ $values { "n"integer } }
{ $description "Like " { $link cleave } ", but instead of taking a single array of quotations, cleaves using quotations taken from the top " { $snippet "n" } " elements of the datastack." }
{ $notes "This word can be used with " { $link apply-curry } " to generalize the " { $snippet "bi-curry@ bi" } " or " { $snippet "tri-curry@ tri" } " dataflow patterns." } ;
HELP:spread*
{ $values { "n"integer } }
{ $description "Like " { $link spread } ", but instead of taking a single array of quotations, spreads using quotations taken from the top " { $snippet "n" } " elements of the datastack." }
{ $notes "This word can be used with " { $link apply-curry } " to generalize the " { $snippet "bi-curry@ bi*" } " or " { $snippet "tri-curry@ tri*" } " dataflow patterns." } ;
HELP:apply-curry
{ $values { "a..." { $snippet "n" } " values on the datastack" } { "quot" quotation } { "n"integer } }
{ $description "Curries each of the top " { $snippet "n" } " items of the datastack onto " { $snippet "quot" } ", leaving " { $snippet "n" } " quotations on the datastack. A generalization of " { $link bi-curry@ } " and " { $link tri-curry@ } "." }
{ $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry@ bi" } ", " { $snippet "tri-curry@ tri" } ", " { $snippet "bi-curry@ bi*" } ", and " { $snippet "tri-curry@ tri*" } "." } ;
HELP:cleave-curry
{ $values { "a"object } { "quot..." { $snippet "n" } " quotations on the datastack" } { "n"integer } }
{ $description "Curries " { $snippet "a" } " onto the " { $snippet "n" } " quotations on the top of the datastack. A generalization of " { $link bi-curry } " and " { $link tri-curry } "." }
{ $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry bi" } ", " { $snippet "tri-curry tri" } ", " { $snippet "bi-curry bi*" } ", and " { $snippet "tri-curry tri*" } "." } ;
HELP:spread-curry
{ $values { "a..." { $snippet "n" } " objects on the datastack" } { "quot..." { $snippet "n" } " quotations on the datastack" } { "n"integer } }
{ $description "Curries the " { $snippet "n" } " quotations on the top of the datastack with the " { $snippet "n" } " values just below them. A generalization of " { $link bi-curry* } " and " { $link tri-curry* } "." }
{ $notes "This word can be used with " { $link cleave* } " and " { $link spread* } " to generalize dataflow patterns such as " { $snippet "bi-curry* bi" } ", " { $snippet "tri-curry* tri" } ", " { $snippet "bi-curry* bi*" } ", and " { $snippet "tri-curry* tri*" } "." } ;
HELP:mnswap
{ $values { "m"integer } { "n"integer } }
{ $description "Swaps the top " { $snippet "m" } " stack elements with the " { $snippet "n" } " elements directly underneath." }
{ $examples
"Some core words expressed in terms of " { $link mnswap } ":"
{ $table
{ { $link swap } { $snippet "1 1 mnswap" } }
{ { $link rot } { $snippet "2 1 mnswap" } }
{ { $link -rot } { $snippet "1 2 mnswap" } }
}
} ;
HELP:nweave
{ $values { "n"integer } }
{ $description "Copies the top " { $snippet "n" } " stack elements underneath each one of the " { $snippet "n" } " elements below." }