[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Aw: [sc-users] Re: non random integer partition



 
i'm not conversant in python, alas, but something seems fishy in there -- what's that about "if p"?
 
in any event, i think the implementation of .implement can give you some good hints:
 
partition { arg parts=2, min=1;
        // randomly partition a number into parts of at least min size :
        var n = this - (min - 1 * parts);
        ^(1..n-1).scramble.keep(parts-1).sort.add(n).differentiate + (min - 1)
    }
 
that's easy to make into a function:
 
(
~partition = { |num, parts=2, min=1|
    var n = num - (min - 1 * parts);
    (1..n-1).scramble.keep(parts-1).sort.add(n).differentiate + (min - 1)
}
)
 
Now all you have to do is get rid of the scramble (collect all possible re-orderings) and the fixed 'parts' (iterate over num-1 possible partition arities) : )
 
fun project, but i have to do xmas stuff ..
 
cheers,
eddi
 
--
https://soundcloud.com/all-n4tural
_______________________________________________ sc-users mailing list info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx archive: https://listarc.bham.ac.uk/marchives/sc-users/ search: https://listarc.bham.ac.uk/lists/sc-users/search/