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

[sc-users] non random integer partition



Hello list !

I want to write code that generate all partition of an integer (and non just
random one like with .partition)

I found this code in Python, and I couldnt make it works in SC

def partitions(n):
    if n==0:
        yield []
        return
        for p in partitions(n-1):
            yield [1]+p
            if p and (len(p)<2 or p[1]>p[0]):
                yield [p[0]+1] + p[1:]

Seems to me pretty straight, but I can't produce something like generator,
also I know Routine can do it, but it's pretty obscur to me...
Someone could tell me the way to achieve that?

Thank you ! 



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/non-random-integer-partition-tp7622273.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
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/