Forums > MaxMSP

identical elements in a list

May 3, 2006 | 3:01 pm

hi,

i have a list which looks like 70 70 43 70 43 22 43 70 22
i simply want to gather all the elements in the list that are identical to each other, and have them sent as a list. so as to have three lists with the identical elements groups:

list1: 70 70 70 70
list2: 43 43 43
list3: 22 22

i tried to work it out with the Match object, but the output of Match is a data stream and not a sequential list.

what shall i do? is there an object which can gather all the identical elements in a list and isolate them into a new one?

all the best,
Spk.


May 3, 2006 | 4:19 pm

maybe the zl object library
can help u…
i dont remember if it is in ma/msp,
by the way u can find it on
maxobjects.com



May 3, 2006 | 4:57 pm

Hi,

the version bellow use only zl objects.

HTH,
ej

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 290 145 104 196617 for the initilisation;
#P comment 131 145 104 196617 extract item by item;
#P comment 111 61 164 196617 sort to group identical values;
#P newex 67 88 40 196617 t b l l;
#P newex 82 349 62 196617 print result;
#P newex 242 213 39 196617 t i b;
#P newex 82 142 47 196617 zl iter 1;
#P newex 242 142 44 196617 zl nth 1;
#P newex 82 179 170 196617 if $i1 == $i2 then $i1 else out2 $i1;
#P newex 82 315 67 196617 zl group 256;
#P newex 67 59 40 196617 zl sort;
#P message 67 28 142 196617 70 70 43 70 43 22 43 70 22;
#P comment 293 215 221 196617 if it’s different output the list of
the last items;
#P connect 2 0 9 0;
#P connect 1 0 2 0;
#P connect 9 1 6 0;
#P connect 6 0 4 0;
#P fasten 7 1 3 0 276 266;
#P connect 7 0 3 0;
#P fasten 9 0 3 0 72 299;
#P connect 4 0 3 0;
#P connect 3 0 8 0;
#P connect 9 2 5 0;
#P fasten 7 0 4 1 247 244 288 244 288 170 247 170;
#P lcolor 15;
#P connect 5 0 4 1;
#P connect 4 1 7 0;
#P window clipboard copycount 13;


May 15, 2006 | 3:48 pm

cheers


Viewing 5 posts - 1 through 5 (of 5 total)