Jan Jakubuv wrote: > 2007/11/15, Ing. Jan Janech <[EMAIL PROTECTED]>: >> Pre milovnikov in-linerov: >> >> >>> variations = lambda lst: [[lst[x]]+y for x in xrange(len(lst)) for >> y in variations(lst[:x]+lst[x+1:])]+(((len(lst) == 1) and [lst]) or []) >> > > nadhera! ale jen tak mimochodem, to sou permutace ;-)
sakra... fakt :D nuz algebra je uz davno za mnou :D To je jedno tak zadefinujem obe: >>> perm = lambda lst: [[lst[x]]+y for x in xrange(len(lst)) for y in perm(lst[:x]+lst[x+1:])]+(((len(lst) == 1) and [lst]) or []) >>> vari = lambda lst, n: list(set(p[:n] for p in perm(lst))) :D :D > > honza. > _______________________________________________ > Python mailing list > [email protected] > http://www.py.cz/mailman/listinfo/python > > > > > _______________________________________________ Python mailing list [email protected] http://www.py.cz/mailman/listinfo/python
