Search code examples
dictionarykdb+

Transform a kdb dictionary into a list


given a dictionary that looks like this:

`a`b`c!((0;3); (1;4); enlist 2)

I'd like to find an elegant way to get the following list as a result: 

`a (index 0)
`b (index 1)
`c (index 2)
`a (index 3)
`b (index 4)

Solution

  • q)d:`a`b`c!((0;3); (1;4); enlist 2)
    q){exec k from `v xasc ungroup ([] k:key x;v:value x)} d
    `a`b`c`a`b