A permutation on permutations
ajs at ix.netcom.com
Sun Nov 25 18:06:28 CET 2001
Simon writes -
>well, i'd like to see this list comprehension
>implemented properly ; it doesn't
>compute as it stands (on 2.1.1)...?
Lots of typos in my previous perms function. This
does work - as per Rainer Deyke's post.
if L ==  :
return [[L[i]] + p for i in range(len(L)) \
for p in perms(L[:i] + L[i+1:])]
>To choose, eg. pick only perms
>whos first entry is less than the last
But now it gets real strange - at least
The following little func does not work as I
Something about the iteration of p in t
with the list.remove().
Is the func as written certifiably bad
Python , or a bug/trap I fell into?
for p in t:
Note that p in t does not iterate over all
items of the original list, so sublists where
p[-1] > p survive!!!
More information about the Python-list