Then, here my small contribution ;) Based on the abstraction [urne] (thx to Frank) from the 'purepd' section on Sourceforge and the messages [add2 $1( instead of [list]x[t l] to accelerate things (thx to Roman). ++
Jack Le mardi 16 mars 2010 à 18:13 +0100, Jack a écrit : > Very clever method. > I have nothing to add :) > ++ > > Jack > > > Le mardi 16 mars 2010 à 16:01 +0100, Frank Barknecht a écrit : > > Hallo, > > Jack hat gesagt: // Jack wrote: > > > > > I just make this abstraction : [list-unique-random] to get a list with > > > random numbers (integers). > > > I didn't see it in the list-abs or in sfruit (am i wrong ?). > > > > > > You can determine : > > > - the range of the random number with an argument or dynamically. > > > - the size wanted of you list with a message. > > > > > > Maybe, this is not an optimized abstraction, so people can modify it. > > > Frank, if you want, you can modify it (my english is not very good) and > > > add it to list-abs. > > > > Thanks a lot for it, Jack. I guess, an object like this would be good to > > have > > in list-abs. I've used the functionality in the past, but never bothered > > with > > an abstraction. I have used my urne.pd then, which is in the "purepd" > > section > > on Sourceforge and a clone of Max'/Cyclone's [urn] (but not zexy's [urn]!). > > It > > seems to deal a bit better with huge numbers like building a list of 1000 > > unique numbers without stack overflows. It's attached. > > > > Ciao > > _______________________________________________ > > [email protected] mailing list > > UNSUBSCRIBE and account-management -> > > http://lists.puredata.info/listinfo/pd-list > > > > _______________________________________________ > [email protected] mailing list > UNSUBSCRIBE and account-management -> > http://lists.puredata.info/listinfo/pd-list
#N canvas 396 35 707 350 10; #X text 231 173 <- the argument is the range of the random number. ; #X text 177 38 <- list length wanted. If this number is upper than the range of the random number then the length is equal at this range (because the random numbers are uniques).; #X obj 141 173 list-urn 10; #X msg 141 39 10; #X msg 161 89 15; #X floatatom 86 88 5 0 0 0 - - -; #X obj 245 222 list-sort; #X obj 141 256 print list-urn; #X obj 245 256 print list-sort; #X text 314 222 <- sort the list from [list-urn]; #X text 238 137 <- you can set dynamically the range of the random number; #X msg 204 137 50; #X connect 2 0 7 0; #X connect 2 0 6 0; #X connect 3 0 2 0; #X connect 4 0 2 0; #X connect 5 0 2 0; #X connect 6 0 8 0; #X connect 11 0 2 1;
#N canvas 656 261 581 387 10; #X obj 157 136 until; #X obj 157 113 max; #X obj 140 85 t b f b b; #X obj 140 58 inlet; #X obj 140 246 outlet; #N canvas 0 0 450 300 message 0; #X obj 163 65 inlet; #X obj 163 225 outlet; #X msg 163 93 6 8 5 2 7 0 3 1 9 4; #X connect 0 0 2 0; #X connect 2 0 1 0; #X restore 140 218 pd message; #X msg 157 188 add2 \$1; #X msg 226 188 set; #X obj 240 58 inlet; #N canvas 0 0 609 671 urne 0; #X obj 228 591 tabread \$0-urn; #X obj 158 541 tabwrite \$0-urn; #X obj 228 470 t a a; #X obj 158 400 - 1; #X obj 107 264 select 0; #X obj 158 513 tabread \$0-urn; #X obj 369 345 outlet; #X obj 228 619 outlet; #X obj 296 33 inlet; #X obj 107 36 inlet; #X obj 296 87 f \$1; #X obj 307 57 loadbang; #X obj 201 84 b; #X obj 228 447 random; #N canvas 689 538 264 239 count-down 0; #X obj 59 66 inlet; #X obj 127 60 inlet; #X obj 59 159 outlet; #X text 123 37 count from?; #X text 54 35 trigger; #X obj 59 96 bang; #X obj 85 131 - 1; #X obj 59 131 f; #X connect 0 0 5 0; #X connect 1 0 7 1; #X connect 5 0 7 0; #X connect 6 0 7 1; #X connect 7 0 6 0; #X connect 7 0 2 0; #X restore 107 231 pd count-down; #X text 365 371 bang if urn empty; #X text 203 641 urn selection; #X msg 228 353 seed \$1; #X obj 228 157 f; #X obj 355 153 table \$0-urn \$1; #X obj 158 372 t a b; #X obj 107 59 route bang seed clear; #N canvas 549 246 251 276 gate_2 0; #X obj 68 18 inlet; #X obj 84 65 inlet; #X obj 68 212 outlet; #X obj 100 191 outlet; #X obj 68 92 f 0; #X obj 68 118 select 0 1; #X obj 68 41 b; #X connect 0 0 6 0; #X connect 1 0 4 1; #X connect 4 0 5 0; #X connect 5 0 2 0; #X connect 5 1 3 0; #X connect 6 0 4 0; #X restore 107 188 pd gate_2; #N canvas 0 0 450 300 init-urn-table 0; #N canvas 0 0 450 300 count 0; #X obj 158 193 + 1; #X obj 122 158 until; #X obj 122 194 f; #X obj 122 101 inlet; #X msg 167 157 0; #X obj 122 120 t a b; #X obj 122 224 outlet; #X connect 0 0 2 1; #X connect 1 0 2 0; #X connect 2 0 0 0; #X connect 2 0 6 0; #X connect 3 0 5 0; #X connect 4 0 2 1; #X connect 5 0 1 0; #X connect 5 1 4 0; #X restore 117 197 pd count; #X obj 117 218 t a a; #X obj 117 249 tabwrite \$0-urn; #X obj 147 173 s \$0-urn; #X msg 147 148 resize \$1; #X obj 117 82 t a a; #X obj 117 49 inlet; #X obj 147 128 change; #X obj 147 105 int; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 1 1 2 1; #X connect 4 0 3 0; #X connect 5 0 0 0; #X connect 5 1 8 0; #X connect 6 0 5 0; #X connect 7 0 4 0; #X connect 8 0 7 0; #X restore 354 131 pd init-urn-table; #X obj 296 107 t b a a a; #X obj 107 288 t b b; #X msg 165 163 0; #X msg 180 186 1; #X connect 0 0 7 0; #X connect 2 0 0 0; #X connect 2 1 1 1; #X connect 3 0 5 0; #X connect 3 0 13 1; #X connect 4 0 25 0; #X connect 4 1 20 0; #X connect 5 0 1 0; #X connect 8 0 10 0; #X connect 9 0 21 0; #X connect 10 0 24 0; #X connect 11 0 10 0; #X connect 12 0 10 0; #X connect 13 0 2 0; #X connect 14 0 4 0; #X connect 17 0 13 0; #X connect 18 0 17 0; #X connect 20 0 3 0; #X connect 20 1 13 0; #X connect 21 0 22 0; #X connect 21 1 18 0; #X connect 21 2 12 0; #X connect 22 0 14 0; #X connect 22 1 6 0; #X connect 24 0 26 0; #X connect 24 1 14 1; #X connect 24 2 13 1; #X connect 24 3 23 0; #X connect 25 0 6 0; #X connect 25 1 27 0; #X connect 26 0 22 1; #X connect 27 0 22 1; #X restore 157 160 pd urne; #X connect 0 0 9 0; #X connect 1 0 0 0; #X connect 2 0 5 0; #X connect 2 1 1 0; #X connect 2 2 9 1; #X connect 2 3 7 0; #X connect 3 0 2 0; #X connect 5 0 4 0; #X connect 6 0 5 0; #X connect 7 0 5 0; #X connect 8 0 9 1; #X connect 9 0 6 0;
_______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
