> The best I've been able to do is pretty obvious:-
> def perms (t):
> if len (t) == 0:
> return []
> else:
> return [[x] + perms ([y for y in t if y <> x]) for x in t]
>
>Needless to say, it doesn't work. It does produce a list of
> lists but they are so horribly n
[Apologies for the long post.]
Hi all,
I have created a "severely restricted" environment within with
users can learn the basics of programming in Python.
Within that environment, I want to have the user test the five
valid forms that an import statement can have, by attempting to
import a fake
On 1 Mai 2005, [EMAIL PROTECTED] wrote:
> I'm trying to produce something of a similar structure to generate the
> permutations of a sequence by translating the ffg bit of Haskell:-
> perms [] = [[]]
> perms xs = [ x : ps | x <- xs , ps <- perms ( xs\\[x]) ]
>
> '\\' applies to lists & means ele
Dear list
I was really impressed by this version of quicksort:-
def qsort (t):
if len (t) == 0:
return []
else:
return qsort([x for x in t[1:] if x <= t[0]]) + [t[0]] +
qsort([x for x in t[1:] if x > t[0]])
I'm trying to produce something of a similar structure to generate the