i’m manipulating values in a dictionary repeatedly and my code ends uplooking like d:key[d]!{some expression}each value dis this normal? :) should i get my dictionary right when i constructit rather than continually changing it?poor example:q)0N!d:a
b!(0 1;2 3)a
b!(0 1;2 3)a| 0 1b| 2 3q)d:key[d]!{(flip enlist x;1 2)}each value dq)da| 0 1 1 2b| 2 3 1 2
each works on dictionaries:q){(flip enlist x;1 2)}each da| 0 1 1 2b| 2 3 1 2
but if you know what you’re adding to it already, can use .?
q).[.;(
d;key d);,;(3 4)]
`.
q)d
a| 0 1 3
b| 2 3 4
q).[`.;(`d;`a);,;(3 4)]
`.
q)d
a| 0 1 3 3 4
b| 2 3 4
In this particular example
,[;1 2]each x
is
x,:1 2
q)d,:1 2
a| 0 1 1 2
b| 2 3 1 2
q).[d;();,:;1 2]
a| 0 1 1 2
b| 2 3 1 2
Cheers,
Attila