Call a function: Difference between revisions
Content added Content deleted
(Added Quackery.) |
|||
Line 4,086: | Line 4,086: | ||
## For partial function application see: |
## For partial function application see: |
||
## http://rosettacode.org/wiki/Partial_function_application#Python</lang> |
## http://rosettacode.org/wiki/Partial_function_application#Python</lang> |
||
=={{header|Quackery}}== |
|||
Words in Quackery take zero or more arguments from the (programmer accessible) data stack, and return zero or more results to the data stack. |
|||
In this dialogue in the Quackery shell, <code>/mod</code> takes two arguments and returns two results, <code>pack</code> takes three arguments (the topmost argument on the stack (<code>2</code>) specifies how many more arguments it is to take from the stack), <code>echo</code> takes one argument and returns no results, and <code>cr</code> takes no arguments and returns no results. |
|||
<pre>/O> 123 7 /mod |
|||
... |
|||
Stack: 17 4 |
|||
/O> 2 pack |
|||
... |
|||
Stack: [ 17 4 ] |
|||
/O> echo cr |
|||
... |
|||
[ 17 4 ] |
|||
Stack empty.</pre> |
|||
Words can also take one or more items (nests, words or numbers) and arbitrary strings of text following the word as arguments. For example, <code>times</code> performs the item following it a specified number of times, and <code>say</code> echoes the string following it to the terminal. |
|||
<pre>/O> 4 times [ 3 times [ say "badger" sp ] cr ] |
|||
... 2 times [ say "mushroom" sp ] cr |
|||
... |
|||
badger badger badger |
|||
badger badger badger |
|||
badger badger badger |
|||
badger badger badger |
|||
mushroom mushroom |
|||
Stack empty. |
|||
</pre> |
|||
=={{header|R}}== |
=={{header|R}}== |