Choosing highest of 3 numbers...?
2 years ago, I was writing a patcher in which I needed to determine which of 3 given numbers was the largest. Eventually the manual reminded me about funbuffs, and I simply filled one with the 3 numbers and sent it the 'max' message. But until I came upon that easy solution, I was startled at the headaches this seemingly simple task was giving me, as a pure MAX process. After more than a year of occasional work at it, this is the simplest solution I could find... and it's still pretty Baroque. Maybe there's something blindingly obvious I overlooked (aside from the funbuff workaround)... but I thought someone might be intrigued to find a simpler solution. I'm obviously still at a fairly elementary level.
Dear David,
Below is a simpler solution (3 objects) without using funbuff...
Yours truly,
David
David Wright wrote:
> 2 years ago, I was writing a patcher in which I needed to determine
> which of 3 given numbers was the largest. Eventually the manual
> reminded me about funbuffs, and I simply filled one with the 3
> numbers and sent it the 'max' message. But until I came upon that
> easy solution, I was startled at the headaches this seemingly simple
> task was giving me, as a pure MAX process. After more than a year of
> occasional work at it, this is the simplest solution I could find...
> and it's still pretty Baroque. Maybe there's something blindingly
> obvious I overlooked (aside from the funbuff workaround)... but I
> thought someone might be intrigued to find a simpler solution. I'm
> obviously still at a fairly elementary level.
this one is simpler :)
_y.
But it doesn't output the index of the highest number - which was
David's request...
Yours truly,
David
e.g.r. wrote:
> this one is simpler :)
> _y.
>
>
> #P window setfont "Sans Serif" 9.;
> #P number 44 132 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 118 62 46 9109513 13 8 21;
> #P message 81 62 34 9109513 3 8 5;
> #P message 44 62 34 9109513 0 1 2;
> #P newex 44 102 73 9109513 maximum;
> #P connect 0 0 4 0;
> #P connect 3 0 0 0;
> #P connect 2 0 0 0;
> #P connect 1 0 0 0;
> #P window clipboard copycount 5;
>
>
> ------------------------------------------------------------------------
>
Ah, yes, the good ol' Swiss-Army-knife mind-bogglingly multi-function ZL! I have to reread that chapter and bone up on it. Thanks for the tip!
Not to be an ingrate, but you could conceivably call this answer just as much a workaround as relying on funbuff. You're passing off the routine from MAX to the code that runs ZL behind the scenes, so to speak. Not that there's anything wrong with that, in practical terms.
Maybe I should clarify my request: using only high-level MAX objects like numbers and binops, create a workflow that shows as clearly and simply as possible this comparison task? I showed the problem to one friend who commented, "Oh, you just enjoy driving yourself nuts!" Point taken. :)
David Wright
ooops, sorry for that.
I should have read more carefully your question ...
_y.
Wow, the board's really hopping on this Saturday morning. 3 more replies came in even while I wrote my "Swiss Army" reply.Thanks for the brainpower, folks...
If you don't need to know the position of highest number, this is
pretty simple:
--
Chris Muir | "There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue." - Brian Eno
JOOST REKVELD WINS THE PRIZE!!!
Well, actually, reading that sentence will be the prize for him. BWAHAHAHAHAA! Of course-- Why didn't I think of *2 and *4! The equivalent of bit-shifting to tag each boolean greater-than test with a different value. I often cram 3 values into a funbuff by multiplying one of them by 100, so 3 12 47 gets stored as 3 1247. Same kinda thinking... sorta.
Profuse thanks to all you contestants. My duplicate posts caused some confusion, as one of them didn't specifically say "greatest number AND ITS INDEX." Of course without that, a 'maximum' routine is simple. OK, back to the real world, for what it's worth.
P.S. I will look into the Peter Elsea collection-- I've read about those before...
David
I don't know if this helps or is, in fact, simpler, but I do remember
scratching my head over this problem too and still might be missing
something blindingly obvious.
It finds the 'index' of lowest number of 5 and I'm sure you can add to
to pass the actual number.
Best
Gorwel
On 20 Jan 2007, at 15:58, David Wright wrote:
>
> 2 years ago, I was writing a patcher in which I needed to determine
> which of 3 given numbers (with its index) was the largest. Eventually
> the manual reminded me about funbuffs, and I simply filled one with
> the 3 numbers and sent it the 'max' message. But until I came upon
> that easy solution, I was startled at the headaches this seemingly
> simple task was giving me, as a 'pure' MAX process. After more than a
> year of occasional work at it, this is the simplest solution I could
> find... and it's still pretty Baroque. Maybe there's something
> blindingly obvious I overlooked (aside from the funbuff workaround)...
> but I thought someone might be intrigued to find a simpler solution.
> I'm obviously still at a fairly elementary level.
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 2;
> #P comment 113 324 57 196617 Which of 3 is highest;
> #P comment 172 325 57 196617 Highest of 3 numbers;
> #P number 142 311 22 9 1 3 8359 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P number 178 312 37 9 0 0 8356 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 175 31 46 196617 13 8 21;
> #P message 138 31 34 196617 3 8 5;
> #P message 101 31 34 196617 0 1 2;
> #P newex 179 290 53 196617 switch 3;
> #P newex 186 268 49 196617 cycle 3;
> #P newex 187 249 61 196617 0 0 0;
> #P newex 187 227 24 196617 3;
> #P newex 142 270 27 196617 + 1;
> #P newex 185 161 23 196617 v g;
> #P newex 121 250 21 196617 v g;
> #P newex 89 138 46 196617 t clear i;
> #P newex 121 228 31 196617 sel;
> #P newex 123 208 27 196617 * 2;
> #P newex 127 188 22 196617 >;
> #P newex 139 161 44 196617 offer;
> #P newex 91 118 27 196617 >;
> #P newex 90 98 51 196617 route 1 0;
> #P newex 96 75 49 196617 funnel 2;
> #P newex 100 55 73 196617 cycle 3;
> #P message 64 216 29 196617 max;
> #N funbuff 0;
> #P newobj 63 232 42 196617 funbuff;
> #P window linecount 5;
> #P comment 7 168 114 196617 This is my 3rd version: if you can come up
> with a simpler one , please let me know... besides the obvious;
> #P fasten 11 1 7 0 130 158 144 158;
> #P fasten 11 1 13 0 130 155 190 155;
> #P connect 10 1 14 0;
> #P fasten 10 1 16 0 149 247 192 247;
> #P connect 10 0 12 0;
> #P fasten 10 0 15 0 163 226 192 226;
> #P connect 7 0 8 1;
> #P fasten 7 0 16 2 144 181 242 181;
> #P connect 4 0 5 0;
> #P fasten 4 0 7 0 98 95 144 95;
> #P fasten 3 2 8 0 167 185 132 185;
> #P fasten 3 2 16 1 217 158;
> #P connect 2 0 1 0;
> #P connect 6 0 11 0;
> #P connect 5 0 6 0;
> #P connect 3 0 4 0;
> #P fasten 21 0 3 0 180 51 105 51;
> #P fasten 20 0 3 0 143 51 105 51;
> #P fasten 19 0 3 0 106 51 105 51;
> #P connect 5 1 6 1;
> #P connect 9 0 10 0;
> #P connect 8 0 9 0;
> #P connect 3 1 4 1;
> #P fasten 11 0 7 0 94 159 144 159;
> #P fasten 12 0 14 0 126 269 147 269;
> #P connect 14 0 23 0;
> #P connect 18 0 22 0;
> #P connect 17 0 18 0;
> #P connect 16 0 17 0;
> #P connect 15 0 16 0;
> #P connect 17 1 18 2;
> #P connect 17 2 18 3;
> #P window clipboard copycount 26;
>
>
Gorwel Owen
www.rhwng.com/banjo.htm
David Wright wrote:
> Wow, the board's really hopping on this Saturday morning. 3 more
> replies came in even while I wrote my "Swiss Army" reply.Thanks for
> the brainpower, folks...
These kind of simple tasks are good for competition, who will come up
with the most elegant solution?
I'd add to that demand the rule, that only built-in objects should be
used, with additional points if it would run in Max 3.6/1.0 as well...
My contribution:
(if you skip the trigger it needs only two objects, but no extra points
for old Max versions, those go to Chris... ;-)
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
jose manuel berenguer wrote:
> i've written a external that identifies the maximum and all of is
> positions in a list. can be downloaded from :
or one more object for the list...:
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com