Deep amend: Difference between revisions

From The K Language Wiki
Content added Content deleted
(Created page with "{{primitive|.[x;y[;f];z]}} '''Deep Amend''', also known as '''dmend''' or '''drill''' is a deep version of Amend which allows modification of elements which are nested de...")
 
("Better category ordering, add redirects to categories, fix pseudo-adverb categories")
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{primitive|.[x;y[;f];z]}}
{{primitive|.[x;y[;f];z]}}


'''Deep Amend''', also known as '''dmend''' or '''drill''' is a deep version of [[Amend]] which allows modification of elements which are nested deep
'''Deep Amend''', also known as '''dmend''' or '''drill''' is a deep version of [[Amend]] which allows modification of elements which are nested deep inside an array.
inside an array.


Deep Amend takes 3 or 4 arguments, where:
Deep 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 route to amend
* <code>y</code> is the index route to amend
* <code>z</code>(optional), is the function to apply to those indices
* <code>z</code> is the function to apply to those indices
* <code>u</code> is the second argument to <code>z</code>
* <code>u</code> (optional), is the second argument to <code>z</code>


It is very similar to [[Amend]] in its functionality. The main difference is that <code>y</code> when given an array indexes into subarrays when used.
It is very similar to [[Amend]] in its functionality. The main difference is that <code>y</code> when given an array indexes into subarrays when used.

<pre> .[3 3#!9;1 1;-:]
0 1 2
3 -4 5
6 7 8</pre>


== ngn/k ==
== ngn/k ==
ngn/k's amend has <code>z</code> as the optional argument, instead of having <code>f</code> as an optional argument.
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 06:14, 9 July 2022

Deep amend
.[x;y[;f];z]

Deep Amend, also known as dmend or drill is a deep version of Amend which allows modification of elements which are nested deep inside an array.

Deep Amend takes 3 or 4 arguments, where:

  • x is an array to amend
  • y is the index route to amend
  • z is the function to apply to those indices
  • u (optional), is the second argument to z

It is very similar to Amend in its functionality. The main difference is that y when given an array indexes into subarrays when used.

 .[3 3#!9;1 1;-:]
0 1 2
3 -4 5
6 7 8

ngn/k[edit]

ngn/k's amend has z as the optional argument, instead of having f as an optional argument.