amend

From The K Language Wiki
Revision as of 04:17, 8 October 2021 by Razetime (talk | contribs) (add amend)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 amend
  • y is the index(or indices) to amend
  • z is the function to be applied to those indices
  • u is an extra argument if z takes two arguments

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