On Apr 9, 2005, at 1:54 PM, [EMAIL PROTECTED] wrote:
Message: 8 Date: Sat, 09 Apr 2005 20:58:49 +0200 From: "Logesh Pillay" <[EMAIL PROTECTED]> Subject: [Tutor] quicksort using list comprehension To: "Discussion for learning programming with Python" <[email protected]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
I'm trying to program quicksort using list comprehension. The following gives me a type mismatch error for "+".
def qsort (t):
if len (t) > 1:
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 know this sounds strange but I have and idea it (or something similar)
worked when I last tried Python a yr or so ago. An earlier version of
Python?
Logesh Pillay
I think the following recipe is what you want:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66473
Rick
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
