Hello, [list-shellsort] should be vanilla compatible (aside from the other [list-abs] abstractions used here -- I think all the ones used are vanilla but I'm not sure - if they're not they're low-level enough that they should be ). It does need the other abstraction Frank mentioned -- [list-swap] swaps two values in a list at the given indices. I've attached it here with a helpfile, and you can find it now in the SVN tree.
https://pure-data.svn.sourceforge.net/svnroot/pure-data/trunk/abstractions/footils/list-abs/list-swap.pd Matt > Date: Tue, 2 Dec 2008 09:53:01 -0500 > From: "Michal Seta" <[EMAIL PROTECTED]> > Subject: Re: [PD] list-sort > To: [email protected] > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi Frank and the bees, > > I obviously haven't updated my list-abs collection in a while. > So much happened while I was asleep... Thanks for the improvements. > I pondered doing reverse sort but I didn't need it *now* :) And I > also figured, there is always [list-rev] which could be used on the > result of [list-sort] and so the latter can be kept simpler. But I > suspect that your solution is less costly than sticking list-rev at > the end of the chain. > > list-shellsort sounds like fun but it is not pd-vanilla compatible. > > Cheers > > ./MiS > > On Tue, Dec 2, 2008 at 7:59 AM, Frank Barknecht <[EMAIL PROTECTED]> wrote: >> Hallo, >> >> oh, and I also now committed two more abstractions that Matt Barber >> sent me offlist, of which one is a sorting abstraction as well. Matt's >> [list-shellsort] uses the Shell sorting algorithm: >> http://en.wikipedia.org/wiki/Shell_sort which generally is a bit >> faster than insertion sort, but I didn't benchmark the two Pd >> implementations (the speed in Pd of course also depends on how much >> element shuffling and list-dripping is needed) >> >> Anyway, currently list-shellsort only does ascending sorting, so I >> just decided to include both Michal's list-sort, which probably is >> easier to understand, and Matt's list-shellsort in the current SVN's >> [list]-abs collection. Choose your poison. ;) >> >> Ciao >> -- >> Frank >> >> Michal Seta hat gesagt: // Michal Seta wrote: >> >>> Hi all, >>> >>> It is amazing how we take things for granted. Most programming >>> languages provide some sort of list sorting function/method. >>> Surprisingly (or not) pd does not (or my search skills are null, or I >>> am not bleeding edge enough). I needed a solution that works with a >>> vanilla pd. >>> >>> I was almost going to do the academia move and announce a pd exam, and >>> have little pd-bees come up with a solution but I needed it *now* else >>> I would not sleep or have terrible nightmares. So here it is. Thank >>> heavens (but give your offerings to fbar's footils shrine) for >>> list-abs. >>> >>> Busy pd-bees, should you care to improve on my solution, please be my >>> guest, I am sure there are better ways of accomplishing this trivial >>> task. In any case, go forth and sort the world around (or within) >>> you. >>> >>> ./MiS
#N canvas 401 249 706 675 10; #X obj 32 27 inlet; #X obj 98 546 outlet; #X obj 217 48 inlet; #X obj 355 59 inlet; #X obj 260 429 list-replace; #X obj 113 400 list-idx; #X obj 260 385 list-idx; #X obj 196 101 f \$1; #X obj 334 105 f \$2; #X obj 113 446 list-replace; #X obj 224 126 s \$0-idx-1; #X obj 358 165 s \$0-idx-2; #X obj 275 323 r \$0-idx-1; #X obj 158 333 r \$0-idx-2; #N canvas 229 564 450 300 \$0-test-range 0; #X obj 46 38 inlet; #X obj 181 48 inlet; #X obj 307 44 inlet; #X obj 46 69 list-len; #X obj 185 119 abs; #X obj 323 121 abs; #X obj 185 95 moses 0; #X obj 323 96 moses 0; #X obj 224 119 + 1; #X obj 362 121 + 1; #X obj 76 118 t f f; #X obj 231 217 &&; #X obj 326 171 >=; #X obj 183 175 >=; #X obj 235 252 outlet; #X connect 0 0 3 0; #X connect 1 0 6 0; #X connect 2 0 7 0; #X connect 3 0 10 0; #X connect 4 0 13 1; #X connect 5 0 12 1; #X connect 6 0 4 0; #X connect 6 1 8 0; #X connect 7 0 5 0; #X connect 7 1 9 0; #X connect 8 0 13 1; #X connect 9 0 12 1; #X connect 10 0 13 0; #X connect 10 1 12 0; #X connect 11 0 14 0; #X connect 12 0 11 1; #X connect 13 0 11 0; #X restore 150 170 pd \$0-test-range; #X obj 85 228 == 0; #X obj 52 253 spigot; #X obj 159 227 spigot; #X obj 32 49 t a a b; #X obj 162 250 t a a a; #X connect 0 0 18 0; #X connect 2 0 7 1; #X connect 3 0 8 1; #X connect 4 0 9 2; #X connect 5 0 9 0; #X connect 6 0 4 0; #X connect 7 0 14 1; #X connect 7 0 10 0; #X connect 8 0 14 2; #X connect 8 0 11 0; #X connect 9 0 1 0; #X connect 12 0 6 1; #X connect 12 0 9 1; #X connect 13 0 5 1; #X connect 13 0 4 1; #X connect 14 0 15 0; #X connect 14 0 17 1; #X connect 15 0 16 1; #X connect 16 0 1 0; #X connect 17 0 19 0; #X connect 18 0 17 0; #X connect 18 0 16 0; #X connect 18 1 14 0; #X connect 18 2 8 0; #X connect 18 2 7 0; #X connect 19 0 5 0; #X connect 19 1 6 0; #X connect 19 2 4 2;
#N canvas 85 208 574 354 10; #X msg 57 84 0 1 2 3 4 5 6 7 8 9 10 11; #X floatatom 145 148 5 0 0 0 - - -; #X floatatom 101 146 5 0 0 0 - - -; #X obj 57 190 list-swap 2 5; #X text 49 19 [list-swap] - swap two elements of a list at given indices. Index values can be negative. If an index value is out of range \, the list is passed with no change.; #X msg 75 114 list a b c d e f g h i j k; #X obj 57 216 prepent set; #X msg 57 241 0 1 5 3 4 2 6 7 8 9 10 11; #X connect 0 0 3 0; #X connect 1 0 3 2; #X connect 2 0 3 1; #X connect 3 0 6 0; #X connect 5 0 3 0; #X connect 6 0 7 0;
_______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
