Forums > MaxMSP

### sorting one group of numbers to match another one

Jun 22 2007 | 12:52 am

I have two groups of numbers, each one in a coll, with one number per "row".

One group is a subset of the other – for example:

group A = 1 3 2 5 4
group B = 1 4 5

I want the ordering of the numbers in group B to follow the pattern set in group A; in the example above, I would like group B to be reordered like so:

1 5 4

I can think of brute force ways to do this, but I was looking for something "elegant" – any takers? I can also use lists rather than colls if that helps…

Thanks,
Dan

Jun 22 2007 | 1:21 am

Not sure if theres an ‘out of the box’ solution I can think of – but if an easier than brute force method exists, I bet you’d find it in L-objects.

Hope this helps

T

Jun 22 2007 | 2:11 am

It does help Tristram – Lswap is exactly what I need. Thanks!

And thanks Peter Elsea!!!

Dan

At 7:21 PM -0600 6/21/07, Tristram Cox wrote:
>Not sure if theres an ‘out of the box’ solution I can think of – but
>if an easier than brute force method exists, I bet you’d find it in
>L-objects.
>
>Hope this helps

Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

Jun 22 2007 | 2:30 am

On 6/21/07 10:11 PM, "Dan Nigrin" wrote:

> It does help Tristram – Lswap is exactly what I need. Thanks!
>
> And thanks Peter Elsea!!!
>
> Dan

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

Jun 22 2007 | 9:56 am

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 112 184 48 9109513;
#P newex 112 158 57 9109513 prepend set;
#P newex 112 131 57 9109513 zl sect;
#P message 159 67 29 9109513 1 4 5;
#P message 112 104 45 9109513 1 3 2 5 4;
#P connect 1 0 0 0;
#P connect 1 0 2 1;
#P connect 3 0 4 0;
#P connect 2 0 3 0;
#P connect 0 0 2 0;
#P window clipboard copycount 5;

Jun 22 2007 | 11:34 am

Thanks for forcing the issue Gary – in building the example I realize
now that it will not work, at least without a bit more work. I just
tried playing around with the Lswap help file, and it all seemed to
work fine there — but that’s because the examples I tried it with
there all included "0" in the list; in my example, in which there’s
no 0 element in the list, it will not work:

#P window setfont "Sans Serif" 9.;
#P message 139 236 75 196617;
#P window linecount 1;
#P newex 139 211 62 196617 prepend set;
#P button 130 133 15 0;
#P newex 170 133 48 196617 loadbang;
#P newex 139 190 36 196617 lswap;
#P message 130 163 34 196617 1 4 5;
#P message 170 162 52 196617 1 3 2 5 4;
#P connect 4 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 6 0;
#P connect 0 0 2 1;
#P connect 3 0 0 0;
#P window clipboard copycount 7;

I’m sure I can find a way around this though…

Dan

At 10:30 PM -0400 6/21/07, Gary Lee Nelson wrote:

Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

Jun 22 2007 | 11:36 am

Interesting, thanks! It seems as though zl sect preserves the order
of the list that is given to it in its left inlet, which does seem
like it will work for my purposes. Plus using native objects!

Thanks again,
Dan

At 2:56 AM -0700 6/22/07, e.g.r. wrote:
>
>#P window setfont "Sans Serif" 9.;
>#P window linecount 1;
>#P message 112 184 48 9109513;
>#P newex 112 158 57 9109513 prepend set;
>#P newex 112 131 57 9109513 zl sect;
>#P message 159 67 29 9109513 1 4 5;
>#P message 112 104 45 9109513 1 3 2 5 4;
>#P connect 1 0 0 0;
>#P connect 1 0 2 1;
>#P connect 3 0 4 0;
>#P connect 2 0 3 0;
>#P connect 0 0 2 0;
>#P window clipboard copycount 5;
>
>

Dan Nigrin
Defective Records
202 Hack / PC-1600 User / VSTi Host / OMS Convert / Jack OS X / Major
Malfunction
http://www.defectiverecords.com
http://www.jackosx.com

Jun 22 2007 | 1:40 pm

Strings of max objects are clumsy for this sort of thing. Perhaps java,
lisp, or my personal favorite, APL (A Programming Language). In APL this is
one line of code. Java and maxlisp (is it UB yet) are already available in
max. APL is a fantasy of mine. What ever happened to pyrite?

On 6/22/07 7:34 AM, "Dan Nigrin" wrote:

> Thanks for forcing the issue Gary – in building the example I realize
> now that it will not work, at least without a bit more work. I just
> tried playing around with the Lswap help file, and it all seemed to
> work fine there — but that’s because the examples I tried it with
> there all included "0" in the list; in my example, in which there’s
> no 0 element in the list, it will not work:

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

Jun 26 2007 | 1:07 pm

Gary Lee Nelson schrieb:
> What ever happened to pyrite?

Turned into Supercollider long ago….

Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
— _|_)—-|—–()————–
———-()——–www.ccmix.com

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

Forums > MaxMSP