>From pytrix:
http://www.american.edu/econ/pytrix/pytrix.py

def permutationsg(lst):
    '''Return generator of all permutations of a list.
    '''
    if len(lst)>1:
        for i in range(len(lst)):
            for x in permutationsg(lst[:i]+lst[i+1:]):
                yield [lst[i]]+x
    else:
        yield lst

hth,
Alan Isaac


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to