# [PD] To divide a number in random parts

Frank Barknecht fbar at footils.org
Sun Mar 6 12:26:26 CET 2011

```On Sat, Mar 05, 2011 at 02:02:09PM -0500, Matt Barber wrote:
> On Sat, Mar 5, 2011 at 1:06 PM, Mathieu Bouchard <matju at artengine.ca> wrote:
> > On Fri, 4 Mar 2011, Matt Barber wrote:
> >
> >> This all sounds about right -- I made [list-shellsort] more as a
> >> pedagogical exercise for my students
> >
> > So, what is that supposed to teach them ?
>
> Right, well -- my students are almost all composers with very little
> experience with computers, except for maybe music engraving software.
> In our computer music program the emphasis has long been on "achieving
> musical results," and the technical training required to make this
> happen tends to be very hard for them. Many of them will look in books
> to find things that interest them, only to get scared by equations,
> block diagrams, bits of code, etc. They all get really excited about
> abstractions in Pd when it comes up, but they don't have any idea why
> or when to make them or use them. It's useful, then, to take concrete
> problems like sorting numbers, finding roots of quadratic equations,
> or making comb filters, for which there exist plenty of code or
> diagram examples, and "translate" them into Pd. At this level just
> getting from an analysis of the problem to "it works" takes a huge
> amount of time; analysis of time complexity would be way outside the
> scope of the course, unfortunately.
>
> >
> >> than as a model of speed or efficiency (I did a "quicksort" as well that
> >> didn't end up in list-abs).
> >
> > How did you achieve the quicksort ?
> >
> > Why didn't it end up in list-abs ?
>
> Attached. It uses a table for all the partitioning, and uses until
> loops instead of the more classic recursion.
>
> >
> >> but then it uses fewer of the list abstractions and is less of an
> >> opportunity to show how the abstractions work "in action."
> >
> > Don't you think that it would be better to show the list-abs for what they
> > are good at, rather than for what they aren't ?
>
> Yes, absolutely. Swapping numbers in a list is hard with vanilla tools
> (and I think [list-swap] could be improved considerably) -- my point
> was that the library seems to prefer using list operations all the way
> through, even if a table/array would be more efficient ultimately.

Well, there might be a slight bias towards list-ops, but table-ops are very
welcome. I guess, I just forgot about the quicksort when it was posted in 2008
in a fury of other sorting implementations. I have added it now.

Ciao
--
Frank Barknecht            Do You RjDj.me?          _ ______footils.org__

```