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