« Return to Thread: tabbing glitch

Re: merging dictionaries

by koonce :: Rate this Message:

Reply to Author | View in Thread


Thanks. That's pretty much what I came up with as well, except that I used
associationDo which transfers the key and value together.

addAll only accepts arrays of associations and I can't see how to demote a
dictionary into an array of associations.

PAUL




On Fri, 22 Feb 2008, Josh Parmenter wrote:

> There doesn't seem to be a merge-like method... would something like
> this work?
>
> a = IdentityDictionary.new;
> a.add(\a -> 1)
> a.add(\b -> 1)
> a.add(\c -> 1)
>
> b = IdentityDictionary.new;
> b.add(\d -> 1)
> b.add(\e -> 1)
> b.add(\f -> 1)
>
> c = IdentityDictionary.new;
>
> [b, a].do({arg aID; // the IdentityDictionary
> aID.keysValuesDo({arg key, val; // parse through its keys and values
> c.add(key -> val)
> })
> })
>
> c;
>
> Best,
>
> Josh
>
> On Feb 22, 2008, at 6:57 PM, koonce@... wrote:
>
>>
>> What is the simplest way to merge IdentityDictionaries, with different
>> keys, into one?
>>
>> Paul Koonce
>>
>>
>> _______________________________________________
>> sc-users mailing list
>> sc-users@...
>> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>
> ******************************************
> /* Joshua D. Parmenter
> http://www.realizedsound.net/josh/
>
> “Every composer – at all times and in all cases – gives his own
> interpretation of how modern society is structured: whether actively
> or passively, consciously or unconsciously, he makes choices in this
> regard. He may be conservative or he may subject himself to continual
> renewal; or he may strive for a revolutionary, historical or social
> palingenesis." - Luigi Nono
> */
>
> _______________________________________________
> sc-users mailing list
> sc-users@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>
_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users

 « Return to Thread: tabbing glitch