Apply a callback to an array: Difference between revisions
Content added Content deleted
(Added Quackery.) |
(→{{header|Quackery}}: added an array-like method.) |
||
Line 2,514: | Line 2,514: | ||
=={{header|Quackery}}== |
=={{header|Quackery}}== |
||
As a dialogue in the Quackery shell (REPL), applying the word <code>cubed</code> to the nest <code>[ 1 2 3 4 5 6 7 8 9 10 ]</code>, first treating the nest as a list, then as an array. |
|||
As a dialog in the Quackery shell (REPL). |
|||
<lang Quackery>/O> [ 3 ** ] is cubed ( n --> n ) |
|||
<pre>/O> ' [ ] |
|||
... |
|||
Stack empty. |
|||
/O> [] |
|||
... ' [ 1 2 3 4 5 6 7 8 9 10 ] |
... ' [ 1 2 3 4 5 6 7 8 9 10 ] |
||
... witheach |
... witheach |
||
... [ cubed join ] |
|||
... |
... |
||
Stack: [ 1 8 27 64 125 216 343 512 729 1000 ] |
Stack: [ 1 8 27 64 125 216 343 512 729 1000 ] |
||
</pre> |
|||
/O> drop |
|||
... ' [ 1 2 3 4 5 6 7 8 9 10 ] |
|||
... dup witheach |
|||
... [ cubed swap i^ poke ] |
|||
... |
|||
Stack: [ 1 8 27 64 125 216 343 512 729 1000 ]</lang> |
|||
=={{header|R}}== |
=={{header|R}}== |