dictionary questions...

MIB's icon

I am trying to get my head around the new dict data structure. I think I am understanding how to use it in a "regular" setting. Here is what I wanted to try but couldn't make work:

I have a data structure that stores several values like pitch, velocity, channel, etc. putting that together with dict.pack is very easy. Now I would like to store each changed structure in a master dict:

{
"note1": ["dataStructureDICT"]
"note2": ["dataStructureDICT"]

"noteX": [....]
}

I assumed that I could use dict.group and append each new dict into my master dict. Problem seems to be that dict.pack doesn't output a new reference for a changed dict but the same one, which means I get the same copy of dict for all my keys...

Is dict supposed to be able to do what I want here? Am I missing something fundamental about this data type?

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks for any clues!!!

keithmanlove's icon

It seems to me that you could do this with a dict of lists, unless you for some reason really want them to be dicts. If there's a way to manipulate these in JS, then you could probably easily make different instances. I haven't had much experience with dicts yet. As I mess with them more, maybe I can get you a better answer.

MIB's icon

true, but I was hoping to be able to do dict of dicts... maybe this isn't the best example. I am just trying to get to know the new data type. I'll keep hunting as well and report back if I find anything else.

Guillaume Bertrand's icon

I'm also interested in a making dicts containing a dynamic amount of dicts. That's why dict.pcak is not what I'm looking for, since the number of dict is static.

Dict.group sounds right but can't figure out how. I keep getting the "dict.group: could not create dictionary from args" error.

Have you found a solution to do so?
Or maybe another way (using js for instance)?
Thanks

Guillaume Bertrand's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Found a way of getting dict.pack to act pretty much as dict.group.
Might help you.

Chris Vik's icon

Guillaume, thanks for the patch! I had a similar task and that fits the bill nicely.