Reputation: 177
I'm trying to setup a function that takes a nested dictionary and replaces each dictionary with a pair of lists:
For example:
$ x:`a`b!(`c`e!20 30;`h`g!(4;`i`j!26 7))
$ dict2List d
(`a`b;((`c`e;20 30);(`h`g;(4;(`i`j;26 7)))))
Any ideas appreciated.
Upvotes: 3
Views: 3002
Reputation: 131
q)f:{[x] value ssr["(",.Q.s1[x],")";"!";";"]}
q)f[x]
a
b
(c
e;20 30;h
g;(4;i
j;26 7))
Upvotes: -1
Reputation: 131
It's just unwrapping dictionaries with (key;value):
q)f:{:$[99h=type x;(key x;.z.s each value x);x]}
q)d:`a`b!(`c`e!20 30;`h`g!(4;`i`j!26 7))
q)f d
(`a`b;((`c`e;20 30j);(`h`g;(4j;(`i`j;26 7j)))))
Upvotes: 2