News for hackers. Stuff that matters.
Re:Python vs Clojure by johnfn on Wednesday October 14, 2009 @03:21PM (#881955)
What bugs me about this article is that the solutions he takes for project euler are taken from a website which tries to make Python into a functional language and are needlessly verbose. For instance, the normal way to solve PE#1 is:

print sum([x for x in range(1001) if x%3==0 and x%5==0)]

Quite a bit shorter than the clojure solution.

Further, their "isPalindrome" function involves a "digits_from_num" call, and is almost 10 lines in total. You could shorten that to one if you check pal == pal[::-1].

Essentially, the guy copied code from a website which wasn't really trying to show off how succinct python could be.

Re:Python vs Clojure by jongraehl on Wednesday October 14, 2009 @04:02PM (#882046)
TypeError: 'int' object is unsubscriptable

You have to use str(pal) first, I guess.

Your core point is right, though; his clojure uses number->string + reverse, and the Python can too.

Re:Python vs Clojure by jbellis on Wednesday October 14, 2009 @04:10PM (#882058)
or perhaps more readably, pal == str(reversed(pal))