Re: [personal kdb+] Re: Another question on dictionaries..

Dict:enlist[`]!enlist()!()

basically you need to stop the list of conforming dictionaries collapsing to a table

q)enlist ab!1 2

a b


1 2

q)(ab!1 2;ab!3 4)

a b


1 2

3 4

q)d:()!()

q)d[`x]:`a`b!1 2                                                                                                                             

q)d 

 | a b

-| —

x| 1 2

and there’s a couple of ways to do that, but essentially you’re looking to keep a entry in the dict value that will stop the collapse (anything but a conforming dict)

q)d:enlist[::]!()

q)d[`x]:`a`b!1 2                                                                                                                             

q)d

::| ()

x| a`b!1 2

Thanks for that.I ended up usingd:()!()d[x]:(1 2)!(3 4)@[d;x;:;((enlist 1)!enlist x))]As I didn’t want any other value left in the dictionary.I guess with your soln I could just have a final stepd:d[x]Thanks,NickOn Feb 9, 2:02?pm, Charles Skelton <char...> wrote:&gt; basically you need to stop the list of conforming dictionaries collapsing to&gt; a table&gt;&gt; q)enlist ab!1 2&gt; a b&gt; ---&gt; 1 2&gt;&gt; q)(ab!1 2;ab!3 4)&gt; a b&gt; ---&gt; 1 2&gt; 3 4&gt;&gt; q)d:()!()&gt; q)d[x]:ab!1 2>> q)d> ?| a b> -| —> x| 1 2>> and there’s a couple of ways to do that, but essentially you’re looking to> keep a entry in the dict value that will stop the collapse (anything but a> conforming dict)>> q)d:enlist[::]!()> q)d[x]:ab!1 2&gt;&gt; q)d&gt; ::| ()&gt; x| ab!1 2>> On Wed, Feb 9, 2011 at 2:44 PM, Charles Skelton <char…> wrote:> > Dict:enlist[]!enlist()!()&gt;&gt; &gt; On Wed, Feb 9, 2011 at 1:15 PM, Nick <nickmcd...> wrote:&gt;&gt; &gt;&gt; Just seeing that Dict[jim]:(yadayada)!(4 5 6 3) is a bad example> >> of a dictionary with non unique keys..>> >> On Feb 9, 11:53 am, Nick <nickmcd…> wrote:> >> > Dict:()!()> >> > Dict[jim]:(yadayada)!(4 5 6 3)&gt; &gt;&gt; &gt; dict[this]:(epic)!(fail)> >> > type&gt;&gt; &gt;&gt; &gt; I think it's failing due to a dict mapping lists and these are atoms&gt;&gt; &gt;&gt; &gt; dict[that]:(enlist epic)!(enlist fail)> >> > type&gt;&gt; &gt;&gt; &gt; anotherdict:(enlist epic)!(enlist `notfail)> >> > works ok>> >> > It’s probably something stupid I’m missing so any input would be> >> > appreciated.>> >> > Thanks,>> >> > Nick>> >> –> >>

Submitted via Google Groups</nickmcd…></nickmcd…></char…></char…>