Next: I/O and Interface, Previous: Named Functions, Up: k9: Manual
These functions modify lists and dictionaries given a list of indices and functions or values to replace.
Replace the values in list / dictionary r at indices i with element f or function f and parameter y. The original list is not modified. Indices are rows for lists and keys for dictionaries.
action | f | y |
amend with element | element | n/a |
amend with element/array | : | element/list |
amend with function 1 param | function | n/a |
amend with function 2 param | function | 2nd param |
Amend to element.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 @[r;0 3;29] / change the first and fourth rows 29 2 3 4 5 29 r / r doesn't change 0 1 2 3 4 5 6
Amend with element/array. If using an array, then the i
and y
must be arrays of equal length.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 @[r;1 2;:;(0;3 5)] 0 1 0 3 5 6
Amend with function f[r] at indices i.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 @[r;1 2;sqrt] 0 1 1.414214 1.732051 2.0 2.236068 6 d:[x:`a`b`c;y:9 4 1];d / dictionary example x|`a`b`c y|9 4 1 @[d;`y;sqrt] x|`a`b`c y|3 2 1.
Amend with function f[r;y] at indices i.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 @[r;1 2;*;10 100] 0 1 20 30 400 500 6 d:[x:`a`b`c;y:9 4 1];d / dictionary x|`a`b`c y|9 4 1 @[d;`y;*;10] x|`a`b`c y|90 40 10
Similar to amend but using i
to fully index r
.
action | f | y |
dmend with element | element | n/a |
dmend with function 1 param | function | n/a |
dmend with function 2 param | function | 2nd param |
Dmend to element.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 .[r;0 1;12] / modify the entry at [0;1] 0 12 2 3 4 5 6
Dmend with function f[r] at indices i.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 .[r;1 1;sqrt] 0 1 2.0 1.732051 4 5 6
Dmend with function f[r;y] at indices i.
r:(0 1;2 3;4 5;6);r 0 1 2 3 4 5 6 .[r;1 1;+;100] 0 1 2 103 4 5 6
Next: I/O and Interface, Previous: Named Functions, Up: k9: Manual