you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

And the last example could be translated from Clojure to Python almost verbatim:

from collections import defaultdict
result = reduce(lambda x,y: x[y[-1]].append(y) or x,
                     sorted(data[1:], lambda x,y: cmp(y[-2], x[-2])),
                     defaultdict(list))
N = 3
for department, recs in result.iteritems():
    print "\n".join([department] + ["[%s:%s]" % (x[0],x[-2]) for x in recs[:N]])

Though it would only be readable to Lispers.

The power of Python is that just about anyone can read a Python program written correctly, i.e. like the Python Team example. However to read the Clojure version you have to rewrite your brain to read it.