Re: One line sort

2021-11-16 Thread Christian Gollwitzer
Am 15.11.21 um 14:10 schrieb ast: A curiosity: q = lambda x: x and q([i for i in x[1:] if i < x[0]]) + [x[0]] + q([i for i in x[1:] if i >= x[0]]) >>> q([7, 5, 9, 0]) [0, 5, 7, 9] That seems to be a translation of the classic Haskell quicksort example: qsort [] = [] qsort (x:xs) = qsort [

Re: One line sort

2021-11-15 Thread Chris Angelico
On Tue, Nov 16, 2021 at 5:58 AM ast wrote: > > A curiosity: > > q = lambda x: x and q([i for i in x[1:] if i < x[0]]) + [x[0]] + q([i > for i in x[1:] if i >= x[0]]) > > >>> q([7, 5, 9, 0]) > [0, 5, 7, 9] A nicely obfuscated quicksort. Although the "one line" part falls down a bit if it has to g

One line sort

2021-11-15 Thread ast
A curiosity: q = lambda x: x and q([i for i in x[1:] if i < x[0]]) + [x[0]] + q([i for i in x[1:] if i >= x[0]]) >>> q([7, 5, 9, 0]) [0, 5, 7, 9] -- https://mail.python.org/mailman/listinfo/python-list