Amend: Difference between revisions
Content added Content deleted
No edit summary |
("Better category ordering, add redirects to categories, fix pseudo-adverb categories") |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{primitive|@[x;y[;z]; |
{{primitive|@[x;y[;f];z]<br>@[x;y;f[;z]]}} |
||
''' |
'''amend''' is a special form of the <code>@</code> verb which takes multiple arguments. |
||
Amend takes 3 or 4 arguments, where: |
Amend takes 3 or 4 arguments, where: |
||
* <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> |
* <code>f</code>(optional), is the function to apply to those indices |
||
* <code> |
* <code>z</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. |
3 argument amend always acts as an element replacement function, since <code>z</code> is [[right|<code>:</code>]] if it is omitted. |
||
Line 22: | Line 22: | ||
@[`v;1;3]; |
@[`v;1;3]; |
||
v |
v |
||
1 |
1 3 3</pre> |
||
== ngn/k == |
== ngn/k == |
||
ngn/k's amend has <code> |
ngn/k's amend has <code>z</code> as the optional argument, instead of having <code>f</code> as an optional argument. |
||
[[Category:Verbs]] |
|||
[[Category:Special forms]] |
|||
[[Category:Primitives]] |
Latest revision as of 05:57, 9 July 2022
Amend
@[x;y[;f];z]
@[x;y;f[;z]]
@[x;y;f[;z]]
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 amendf
(optional), is the function to apply to those indicesz
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 3 3
ngn/k[edit]
ngn/k's amend has z
as the optional argument, instead of having f
as an optional argument.