'change nested Keyed dictionaries into nested lists of just the keys KDB+/Q

I have a (0h) list (named result) of keyed dictionaries, keyed on `RIC.

I want to extract the list of RICs for each entry of result and store it in a different list that simply has the nested lists of RICs for each index. I need to be able to apply a function to each list of RICs sequentially by index, and can't figure out how to do it since result has keyed dictionaries instead of lists (the keyed dictionaries have other columns too, but RIC is the only one I'm interested in)

Sorry if this explanation is poor, but I'm really not sure how to go about this. Any advice is greatly appreciated!



Solution 1:[1]

You have a list of keyed tables. Therefore, you can use qSQL to exec the RIC column from each:

{exec RIC from x}each result

Solution 2:[2]

You have a list of keyed dictionaries. Its type is 0, so we know the dictionary keys vary.

Index At Each is all you need:

q)show dd:(`one`two`three`four`five,'`RIC)!'(`bar;)each(2+5?5)?'`3
`one`RIC!(`bar;`oco`khd`dga`eob)
`two`RIC!(`bar;`iog`edg`kio)
`three`RIC!(`bar;`gme`iko`cje`ijj)
`four`RIC!(`bar;`dlm`klp`epj`bji`gph)
`five`RIC!(`bar;`lfm`mci`pal`eho`kgi`enf)
q)type dd
0h
q)dd@'`RIC
`oco`khd`dga`eob
`iog`edg`kio
`gme`iko`cje`ijj
`dlm`klp`epj`bji`gph
`lfm`mci`pal`eho`kgi`enf

q)(dd@'`RIC) ~ {exec RIC from x}each dd
1b
q)\ts:10000 {exec RIC from x}each dd
18 1456
q)\ts:10000 dd@'`RIC
5 736

(Will also work with a list of keyed tables.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kylebonnes
Solution 2 SJT