comprehending comprehensions
Maurix
maurix78_remove_this_ at wanadoo.es
Sun Jun 15 06:42:34 EDT 2003
Thanks for the ideas,
But, what about the order? If we want to be "fuctional" the order is not
to be important:
qsort=lambda l : len(l) > 1 and (...)
(...) qsort(elts_lt_x(l))+[l[0]]+qsort(elts_greq_x(l)) or l
elts_lt_x=lambda l : [y for y in l[1:] if y<l[0]]
elts_greq_x=lambda l : [y for y in l[1:] if y>=l[0]]
My aim is not to put all in a line, (if you want you can put the qsort
in c in the same line!!) but use a similar sintaxis of a pure functional
language.
I think "structurally" because i'm a c programmer but learning Python
i'm apreciating his functional style. Python permit it but, we think
functionally when we make algorithms?
More information about the Python-list
mailing list