Search code examples
kdbq-lang

Update value in dictionary for q lang (kdb+)


How I may update values in q dictionary use functional way?

Example:

x: `1`2`3;
d: x!x;
show[d];
// d -> 
// 1 | 1
// 2 | 2
// 3 | 3
// TODO change d: 
show[d];
// d -> 
// 1 | 11
// 2 | 22
// 3 | 3

Solution

  • You may change you dictionary in this way:

    // @[dictionary name; list of keys; ?; list of values];
    @[d; `1`2; :; `11`22];