Amend: Difference between revisions
Content added Content deleted
(add amend) |
No edit summary |
||
Line 1: | Line 1: | ||
{{primitive|@[x;y;z |
{{primitive|@[x;y[;z];u]}} |
||
'''Amend''' is a special form of the <code>@</code> verb which takes multiple arguments. |
'''Amend''' is a special form of the <code>@</code> verb which takes multiple arguments. |
||
Line 6: | Line 6: | ||
* <code>x</code> is an array to amend |
* <code>x</code> is an array to amend |
||
* <code>y</code> is the index(or indices) to amend |
* <code>y</code> is the index(or indices) to amend |
||
* <code>z</code> is the function to |
* <code>z</code>(optional), is the function to apply to those indices |
||
* <code>u</code> is |
* <code>u</code> is the second argument to <code>z</code> |
||
3 argument amend always acts as an element replacement function, since <code>z</code> is [[right|<code>:</code>]] if it is omitted. |
|||
<code>x</code> can be a value or a symbol. If given a symbol, amend will modify the variable that is indicated by the symbol. |
<code>x</code> can be a value or a symbol. If given a symbol, amend will modify the variable that is indicated by the symbol. |
||
Line 14: | Line 16: | ||
v |
v |
||
1 2 3 |
1 2 3 |
||
@[v;1 |
@[v;1;3] |
||
1 3 3 |
1 3 3 |
||
v |
v |
||
1 2 3 |
1 2 3 |
||
@[`v;1 |
@[`v;1;3]; |
||
v |
v |
||
1 2 3</pre> |
1 2 3</pre> |
||
== ngn/k == |
|||
ngn/k's amend has <code>u</code> as the optional argument, instead of having <code>z</code> as an optional argument. |
Revision as of 05:57, 8 October 2021
Amend
@[x;y[;z];u]
Amend is a special form of the @
verb which takes multiple arguments.
Amend takes 3 or 4 arguments, where:
x
is an array to amendy
is the index(or indices) to amendz
(optional), is the function to apply to those indicesu
is the second argument toz
3 argument amend always acts as an element replacement function, since z
is :
if it is omitted.
x
can be a value or a symbol. If given a symbol, amend will modify the variable that is indicated by the symbol.
v:1 2 3 v 1 2 3 @[v;1;3] 1 3 3 v 1 2 3 @[`v;1;3]; v 1 2 3
ngn/k
ngn/k's amend has u
as the optional argument, instead of having z
as an optional argument.