Revision: 10366 http://pure-data.svn.sourceforge.net/pure-data/?rev=10366&view=rev Author: fbar Date: 2008-11-06 10:47:07 +0000 (Thu, 06 Nov 2008)
Log Message: ----------- added list sort from Jack
Added Paths: ----------- trunk/abstractions/footils/list-abs/list-sort-help.pd trunk/abstractions/footils/list-abs/list-sort.pd
Added: trunk/abstractions/footils/list-abs/list-sort-help.pd =================================================================== --- trunk/abstractions/footils/list-abs/list-sort-help.pd (rev 0) +++ trunk/abstractions/footils/list-abs/list-sort-help.pd 2008-11-06 10:47:07 UTC (rev 10366) @@ -0,0 +1,50 @@ +#N canvas 420 190 744 496 10; +#X text 431 386 2008 Jack/RYBN; +#X msg 85 77 10; +#X text 188 249 Descendent; +#X text 175 227 Ascendent (default); +#X msg 85 340 44 39 27 10 10 8 5 -4 -14 -36; +#X text 123 76 <- generate a random list with 10 elements; +#X obj 85 311 prepent set; +#X msg 85 151 -36 5 44 8 39 -14 10 -4 27 10; +#X text 62 27 [list-sort] : sort a list of numbers. Elements of other +type (symbols , ...) are removed from the list.; +#N canvas 0 0 450 300 mklist 0; +#X obj 109 146 random 100; +#X obj 109 124 until; +#X msg 215 150 set; +#X msg 109 188 add2 $1; +#X obj 86 94 t b f b; +#X obj 109 167 - 50; +#X obj 86 63 inlet; +#X obj 86 237 outlet; +#X connect 0 0 5 0; +#X connect 1 0 0 0; +#X connect 2 0 7 0; +#X connect 3 0 7 0; +#X connect 4 0 7 0; +#X connect 4 1 1 0; +#X connect 4 2 2 0; +#X connect 5 0 3 0; +#X connect 6 0 4 0; +#X restore 85 116 pd mklist; +#X msg 371 338 44 39 27 10 10 8 5 -4 -14 -36; +#X obj 371 309 prepent set; +#X msg 145 228 asc; +#X msg 153 249 desc; +#X obj 466 192 hradio 15 1 0 2 empty empty empty 0 -8 0 10 -262144 +-1 -1 0; +#X obj 85 283 list-sort; +#X text 485 217 Arg can be "asc"/0 or "desc"/1; +#X obj 371 221 list-sort desc; +#X connect 1 0 9 0; +#X connect 6 0 4 0; +#X connect 7 0 15 0; +#X connect 7 0 17 0; +#X connect 9 0 7 0; +#X connect 11 0 10 0; +#X connect 12 0 15 1; +#X connect 13 0 15 1; +#X connect 14 0 17 1; +#X connect 15 0 6 0; +#X connect 17 0 11 0;
Added: trunk/abstractions/footils/list-abs/list-sort.pd =================================================================== --- trunk/abstractions/footils/list-abs/list-sort.pd (rev 0) +++ trunk/abstractions/footils/list-abs/list-sort.pd 2008-11-06 10:47:07 UTC (rev 10366) @@ -0,0 +1,166 @@ +#N canvas 395 80 787 477 10; +#X obj 55 40 inlet; +#N canvas 452 289 450 300 init 0; +#X obj 122 56 inlet; +#X obj 122 197 outlet; +#X obj 122 84 t a a b; +#X obj 161 111 s $0-init; +#X obj 141 142 list-len; +#X obj 141 167 s $0-len; +#X text 231 110 <- send bang to init some objects; +#X text 205 166 <- send the length of the list; +#X connect 0 0 2 0; +#X connect 2 0 1 0; +#X connect 2 1 4 0; +#X connect 2 2 3 0; +#X connect 4 0 5 0; +#X restore 55 70 pd init; +#X text 112 68 <- init; +#X obj 55 270 t a a; +#X obj 55 99 list-drip; +#X obj 136 210 r $0-init; +#X obj 212 210 r $0-sort; +#X obj 581 45 inlet; +#X obj 55 155 t f f; +#X obj 55 359 outlet; +#X obj 87 292 s $0-listtosort; +#N canvas 111 181 880 518 test 0; +#X obj 391 210 list-find; +#X msg 391 189 1; +#X obj 391 263 once; +#X obj 45 143 list-len; +#X obj 45 459 outlet; +#X obj 45 307 list; +#X obj 60 200 r $0-len; +#X obj 45 225 sel; +#X obj 45 165 t f f; +#X obj 66 277 r $0-sort; +#X obj 45 122 t a a; +#X obj 45 92 list-apply >; +#X obj 45 66 spigot 1; +#X obj 263 92 list-apply <; +#X obj 263 66 spigot 0; +#X obj 45 16 inlet; +#X obj 332 66 r $0-newelementtotest; +#X obj 114 66 r $0-newelementtotest; +#X text 351 91 <- the position of the new element must be between the +0 and 1 returned by [list-apply]; +#X text 460 207 <- find the first 1 in the list returned by [list-apply] +and return its position; +#X obj 181 426 s $0-sort; +#X text 769 468 2008 Jack/RYBN; +#X text 521 262 <- the 1 exist or not ? if it exist then sort the list +(red part) if not do nothing (green part); +#X obj 391 165 t b b a; +#X obj 482 263 == 0; +#X obj 442 263 != 0; +#X obj 174 294 cnv 15 200 125 empty empty empty 20 12 0 14 -258113 +-66577 0; +#X obj 384 294 cnv 15 100 50 empty empty empty 20 12 0 14 -4034 -66577 +0; +#X obj 181 223 t b f; +#X obj 181 326 list-idx 2; +#X obj 181 267 list; +#X obj 181 202 - 1; +#X obj 181 371 list-insert; +#X obj 181 394 list-delete -1 1; +#X obj 181 302 spigot; +#X obj 202 246 r $0-init; +#X obj 264 246 r $0-listtosort; +#X obj 244 347 r $0-listtosort; +#X obj 391 301 spigot; +#X text 96 459 <- when all elements have been sent by [list-drip] , +a bang is sent to [list] to output the last list send by the red part +or green part; +#X obj 90 42 r $0-isasc; +#X obj 308 42 r $0-isdesc; +#X connect 0 0 2 0; +#X connect 0 1 24 0; +#X connect 0 1 25 0; +#X connect 1 0 0 0; +#X connect 2 0 32 1; +#X connect 3 0 8 0; +#X connect 5 0 4 0; +#X connect 6 0 7 1; +#X connect 7 0 5 0; +#X connect 8 0 7 0; +#X connect 8 1 31 0; +#X connect 9 0 5 1; +#X connect 10 0 3 0; +#X connect 10 1 23 0; +#X connect 11 0 10 0; +#X connect 12 0 11 0; +#X connect 13 0 10 0; +#X connect 14 0 13 0; +#X connect 15 0 12 0; +#X connect 15 0 14 0; +#X connect 16 0 13 2; +#X connect 17 0 11 2; +#X connect 23 0 1 0; +#X connect 23 1 2 1; +#X connect 23 2 0 1; +#X connect 24 0 38 1; +#X connect 25 0 34 1; +#X connect 28 0 30 0; +#X connect 28 1 29 1; +#X connect 29 0 32 0; +#X connect 30 0 34 0; +#X connect 30 0 38 0; +#X connect 31 0 28 0; +#X connect 32 0 33 0; +#X connect 33 0 20 0; +#X connect 34 0 29 0; +#X connect 35 0 30 1; +#X connect 36 0 30 1; +#X connect 37 0 32 2; +#X connect 38 0 20 0; +#X connect 40 0 12 1; +#X connect 41 0 14 1; +#X restore 55 331 pd test; +#X obj 87 181 s $0-newelementtotest; +#X text 489 344 2008 Jack/RYBN; +#X text 114 329 <- test position of the new value and sort it if needed +; +#X text 125 97 <- send elements one after another; +#X text 152 245 <- place the new element from [list-drip] to the end +of the new sorted list; +#X obj 55 243 list prepend; +#X text 294 211 <- receive the new list sorted; +#X obj 55 128 route float; +#X obj 129 150 print Warning:_Only_float_lists_can_be_sorted; +#X obj 634 76 list append $1; +#X obj 634 100 list trim; +#X obj 634 52 loadbang; +#X obj 581 278 s $0-isasc; +#X obj 648 258 s $0-isdesc; +#X obj 581 230 unpack 0 0; +#X msg 581 197 1 0; +#X msg 628 196 0 1; +#X obj 581 132 route asc desc; +#X obj 676 153 route 0 1; +#X connect 0 0 1 0; +#X connect 1 0 4 0; +#X connect 3 0 11 0; +#X connect 3 1 10 0; +#X connect 4 0 19 0; +#X connect 5 0 17 1; +#X connect 6 0 17 1; +#X connect 7 0 29 0; +#X connect 8 0 17 0; +#X connect 8 1 12 0; +#X connect 11 0 9 0; +#X connect 17 0 3 0; +#X connect 19 0 8 0; +#X connect 19 1 20 0; +#X connect 21 0 22 0; +#X connect 22 0 29 0; +#X connect 23 0 21 0; +#X connect 26 0 24 0; +#X connect 26 1 25 0; +#X connect 27 0 26 0; +#X connect 28 0 26 0; +#X connect 29 0 27 0; +#X connect 29 1 28 0; +#X connect 29 2 30 0; +#X connect 30 0 27 0; +#X connect 30 1 28 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.