Eliminate redundancy in a stream of number

May 26, 2006 at 9:10pm

Eliminate redundancy in a stream of number

#26174
May 26, 2006 at 9:51pm

This should do it.

max v2;
#N vpatcher 10 59 951 659;
#P window setfont “Sans Serif” 9.;
#P window linecount 3;
#P comment 221 80 108 196617 filter clear message form input stream of
integers;
#P window linecount 4;
#P comment 112 285 108 196617 clear empties the look up table. all new
numbers will pass again.;
#P window linecount 3;
#P comment 210 379 108 196617 close gate when a number that has been passed
is lookedup;
#P window linecount 2;
#P comment 419 287 85 196617 store numbers that have passed;
#P window linecount 1;
#P comment 180 212 55 196617 set lookup;
#P comment 297 213 64 196617 send to gate;
#P comment 417 214 66 196617 check lookup;
#P button 109 144 15 0;
#P newex 109 262 40 196617 t clear;
#P newex 172 235 45 196617 pack i 0;
#N coll ;
#P newobj 408 266 53 196617 coll;
#P toggle 174 378 15 0;
#P newex 168 78 49 196617 sel clear;
#P newex 174 401 29 196617 gate;
#P newex 172 194 366 196617 t i i i 1;
#N comlet non-repeated integers;
#P outlet 174 437 15 0;
#N comlet stream of integers and clear message;
#P inlet 168 53 15 0;
#P comment 535 214 52 196617 open gate;
#P fasten 5 0 10 0 173 99 114 99;
#P connect 10 0 9 0;
#P connect 1 0 5 0;
#P fasten 5 1 3 0 212 106 177 106;
#P connect 3 0 8 0;
#P fasten 7 0 6 0 413 361 179 361;
#P fasten 3 3 6 0 531 361 179 361;
#P connect 6 0 4 0;
#P connect 4 0 2 0;
#P connect 3 1 4 1;
#P fasten 9 0 7 0 114 284 401 284 401 262 413 262;
#P fasten 8 0 7 0 177 260 413 260;
#P fasten 3 2 7 0 413 226 413 226;
#P pop;

#77841
May 26, 2006 at 9:58pm

There’s not an object that does this, there’s lots of different ways of
implementing it. Here’s one way using table and histo. Coll would
also be very good for this task.

Peter McCulloch

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 445 495 107 196617 Start all over again…;
#P newex 401 515 64 196617 s tableClear;
#P message 401 492 33 196617 clear;
#P newex 401 441 40 196617 change;
#P newex 401 464 32 196617 sel 1;
#P comment 520 336 157 196617 just to make things interesting…;
#P newex 300 622 178 196617 noteout;
#P newex 300 589 94 196617 makenote 127 100;
#P newex 284 39 77 196617 r StreamSpeed;
#P newex 416 346 77 196617 s StreamSpeed;
#P newex 416 324 99 196617 scale 0 100 200 20;
#P window linecount 2;
#P comment 448 399 100 196617 If all points from 0 – 100 are filled…;
#P window linecount 1;
#P comment 450 250 265 196617 add the pair of values , and find the
total sum of the table;
#P newex 330 249 64 196617 r tableClear;
#P newex 186 137 64 196617 r tableClear;
#P toggle 401 420 15 0;
#P number 401 302 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 401 395 42 196617 >= 101;
#P newex 401 249 41 196617 t sum l;
#P window linecount 2;
#P comment 461 199 100 196617 If a number has been used , 1 , else 0;
#P window linecount 1;
#P newex 17 135 64 196617 s tableClear;
#P newex 401 228 42 196617 pack i i;
#P newex 433 199 27 196617 > 0;
#P number 284 61 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 12.;
#N vtable 101 907 195 1117 362 9705 2 foo;
#P newobj 401 276 64 196620 table foo;
#P window setfont “Sans Serif” 9.;
#P message 17 112 33 196617 clear;
#P button 191 585 55 0;
#P user hslider 191 554 18 128 100 1 0 0;
#P number 191 523 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 514 115 855 568;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P message 65 313 39 196617 set $1;
#P window linecount 1;
#P newex 143 252 31 196617 t b 1;
#P newex 143 228 32 196617 sel 1;
#P newex 143 205 27 196617 < 5;
#P newex 143 179 64 196617 random 101;
#P newex 143 158 32 196617 sel 1;
#P newex 143 136 30 196617 > 20;
#N counter 1 100;
#X flags 0 0;
#P newobj 143 108 74 196617 counter 1 100;
#P newex 143 283 64 196617 random 101;
#P inlet 98 48 15 0;
#P newex 50 71 58 196617 metro 300;
#P newex 50 336 76 196617 drunk 100 -12;
#P inlet 50 51 15 0;
#P outlet 50 361 15 0;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P connect 13 0 2 0;
#P connect 2 0 0 0;
#P fasten 5 0 13 0 148 306 70 306;
#P connect 4 0 3 1;
#P fasten 3 0 6 0 55 98 148 98;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 5 0;
#P fasten 12 1 6 2 169 275 233 275 233 98 180 98;
#P pop;
#P newobj 169 84 125 196617 p GenerateNumberStream;
#P toggle 169 58 15 0;
#P newex 191 490 32 196617 gate;
#P newex 191 454 30 196617 < = 1;
#P number 169 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 169 161 32 196617 histo;
#P window linecount 2;
#P comment 482 270 100 196617 see the values that have been entered;
#P connect 10 0 15 0;
#P connect 5 0 6 0;
#P connect 6 0 2 0;
#P connect 21 0 1 0;
#P connect 2 0 1 0;
#P connect 1 1 3 0;
#P connect 3 0 4 0;
#P connect 4 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 9 0;
#P fasten 1 0 4 1 174 483 218 483;
#P connect 27 0 12 0;
#P connect 12 0 6 1;
#P connect 8 0 28 0;
#P connect 28 0 29 0;
#P connect 28 1 29 1;
#P connect 1 0 14 0;
#P connect 14 0 17 0;
#P connect 22 0 11 0;
#P connect 17 1 11 0;
#P connect 17 0 11 0;
#P connect 11 0 19 0;
#P connect 19 0 18 0;
#P connect 18 0 20 0;
#P connect 20 0 32 0;
#P connect 32 0 31 0;
#P connect 31 0 33 0;
#P connect 33 0 34 0;
#P connect 19 0 25 0;
#P connect 25 0 26 0;
#P connect 1 1 13 0;
#P connect 13 0 14 1;
#P window clipboard copycount 36;

#77842
May 26, 2006 at 10:30pm

#77843
May 27, 2006 at 1:51am

How about urn and my Deal and BigUrn objects. Peter Castine’s lp.ernie also
outputs random numbers without repetition.

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

#77844

You must be logged in to reply to this topic.