1 USING: help.syntax help.markup kernel sequences quotations
\r
6 { $values { "n" integer } }
\r
7 { $description "A generalization of " { $link 1array } ", "
\r
8 { $link 2array } ", " { $link 3array } " and " { $link 4array } " "
\r
9 "that constructs an array from the top " { $snippet "n" } " elements of the stack."
\r
13 { $values { "n" integer } }
\r
14 { $description "A generalization of " { $link first } ", "
\r
15 { $link first2 } ", " { $link first3 } " and " { $link first4 } " "
\r
16 "that pushes the first " { $snippet "n" } " elements of a sequence on the stack."
\r
20 { $values { "n" integer } }
\r
21 { $description "A generalization of " { $link dup } ", "
\r
22 { $link over } " and " { $link pick } " that can work "
\r
23 "for any stack depth. The nth item down the stack will be copied and "
\r
24 "placed on the top of the stack."
\r
27 { $example "USING: prettyprint generalizations ;" "1 2 3 4 4 npick .s" "1\n2\n3\n4\n1" }
\r
29 { $see-also dup over pick } ;
\r
32 { $values { "n" integer } }
\r
33 { $description "A generalization of " { $link dup } ", "
\r
34 { $link 2dup } " and " { $link 3dup } " that can work "
\r
35 "for any number of items. The n topmost items on the stack will be copied and "
\r
36 "placed on the top of the stack."
\r
39 { $example "USING: prettyprint generalizations ;" "1 2 3 4 4 ndup .s" "1\n2\n3\n4\n1\n2\n3\n4" }
\r
41 { $see-also dup 2dup 3dup } ;
\r
44 { $values { "n" integer } }
\r
45 { $description "A generalization of " { $link nip } " and " { $link 2nip }
\r
47 "for any number of items."
\r
50 { $example "USING: prettyprint generalizations ;" "1 2 3 4 3 nnip .s" "4" }
\r
52 { $see-also nip 2nip } ;
\r
55 { $values { "n" integer } }
\r
56 { $description "A generalization of " { $link drop }
\r
58 "for any number of items."
\r
61 { $example "USING: prettyprint generalizations ;" "1 2 3 4 3 ndrop .s" "1" }
\r
63 { $see-also drop 2drop 3drop } ;
\r
66 { $values { "n" integer } }
\r
67 { $description "A generalization of " { $link rot } " that works for any "
\r
68 "number of items on the stack. "
\r
71 { $example "USING: prettyprint generalizations ;" "1 2 3 4 4 nrot .s" "2\n3\n4\n1" }
\r
73 { $see-also rot -nrot } ;
\r
76 { $values { "n" integer } }
\r
77 { $description "A generalization of " { $link -rot } " that works for any "
\r
78 "number of items on the stack. "
\r
81 { $example "USING: prettyprint generalizations ;" "1 2 3 4 4 -nrot .s" "4\n1\n2\n3" }
\r
83 { $see-also rot nrot } ;
\r
86 { $values { "n" integer } }
\r
87 { $description "A generalization of " { $link spin } " that reverses any number of items at the top of the stack."
\r
90 { $example "USING: prettyprint generalizations ;" "1 2 3 4 4 nrev .s" "4\n3\n2\n1" }
\r
92 { $see-also rot nrot } ;
\r
95 { $values { "quot" quotation } { "n" number } }
\r
96 { $description "A generalization of " { $link dip } " that can work "
\r
97 "for any stack depth. The quotation will be called with a stack that "
\r
98 "has 'n' items removed first. The 'n' items are then put back on the "
\r
99 "stack. The quotation can consume and produce any number of items."
\r
102 { $example "USING: generalizations kernel prettyprint ;" "1 2 [ dup ] 1 ndip .s" "1\n1\n2" }
\r
103 { $example "USING: generalizations kernel prettyprint ;" "1 2 3 [ drop ] 2 ndip .s" "2\n3" }
\r
105 { $see-also dip 2dip } ;
\r
108 { $values { "n" number } }
\r
109 { $description "A generalization of " { $link slip } " that can work "
\r
110 "for any stack depth. The first " { $snippet "n" } " items after the quotation will be "
\r
111 "removed from the stack, the quotation called, and the items restored."
\r
114 { $example "USING: generalizations prettyprint ;" "[ 99 ] 1 2 3 4 5 5 nslip .s" "99\n1\n2\n3\n4\n5" }
\r
116 { $see-also slip nkeep } ;
\r
119 { $values { "quot" quotation } { "n" number } }
\r
120 { $description "A generalization of " { $link keep } " that can work "
\r
121 "for any stack depth. The first " { $snippet "n" } " items after the quotation will be "
\r
122 "saved, the quotation called, and the items restored."
\r
125 { $example "USING: generalizations kernel prettyprint ;" "1 2 3 4 5 [ drop drop drop drop drop 99 ] 5 nkeep .s" "99\n1\n2\n3\n4\n5" }
\r
127 { $see-also keep nslip } ;
\r
129 ARTICLE: "generalizations" "Generalized shuffle words and combinators"
\r
130 "A number of stack shuffling words and combinators for use in "
\r
131 "macros where the arity of the input quotations depends on an "
\r
133 { $subsection narray }
\r
134 { $subsection firstn }
\r
135 { $subsection ndup }
\r
136 { $subsection npick }
\r
137 { $subsection nrot }
\r
138 { $subsection -nrot }
\r
139 { $subsection nnip }
\r
140 { $subsection ndrop }
\r
141 { $subsection nrev }
\r
142 { $subsection ndip }
\r
143 { $subsection nslip }
\r
144 { $subsection nkeep }
\r
145 { $subsection ncurry }
\r
146 { $subsection nwith }
\r
147 { $subsection napply } ;
\r
149 ABOUT: "generalizations"
\r