Variadic function: Difference between revisions
Content added Content deleted
(Added Quackery.) |
|||
Line 2,176: | Line 2,176: | ||
(sugar in varargs 1) |
(sugar in varargs 1) |
||
</lang> |
</lang> |
||
=={{header|Quackery}}== |
|||
A Quackery word can take a variable number of items from the stack, either by specifying the number of items on the top of stack, or by placing a marker on the stack underneath a number of items. |
|||
(<code>oats</code>: "'''o'''ne '''a'''nd '''t'''he '''s'''ame" compares the ''identity'' of two items, ensuring that <code>marker</code> is uniquely identified.) |
|||
<lang Quackery>[ pack witheach |
|||
[ echo$ cr ] ] is counted-echo$ ( $ ... n --> ) |
|||
[ this ] is marker ( --> m ) |
|||
[ [] |
|||
[ swap dup marker oats |
|||
iff drop done |
|||
nested swap join again ] |
|||
witheach |
|||
[ echo$ cr ] ] is markered-echo$ ( m $ ... --> ) |
|||
$ "this" $ "is" $ "a" $ "formica" $ "table" 5 counted-echo$ |
|||
cr |
|||
marker $ "green" $ "is" $ "it's" $ "colour" markered-echo$</lang> |
|||
{{out}} |
|||
<pre>this |
|||
is |
|||
a |
|||
formica |
|||
table |
|||
green |
|||
is |
|||
it's |
|||
colour |
|||
</pre> |
|||
=={{header|R}}== |
=={{header|R}}== |