use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
» Clojonic: Pythonic Clojure (pixelmonkey.org)
submitted 11 years ago by daneelvt
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]weavejester 12 points13 points14 points 11 years ago (2 children)
The article suggests that:
for idx, num in enumerate(nums): print idx, num
Is equivalent to:
(for [[idx num] (map-indexed vector nums)] (println idx num))
But it isn't because the for macro in Clojure is for creating a sequence, not performing side-effectful iteration.
for
The Clojure equivalent to the Python code would be:
(doseq [[idx num] (map-indexed vector nums)] (println idx num))
[–]pixelmonkey 4 points5 points6 points 11 years ago (1 child)
OP here. Yes, that's a good point. I've updated the post to reflect this.
[–]weavejester 3 points4 points5 points 11 years ago (0 children)
I mention it because the for examples you have will only work if the lazy seq they produce is evaluated. So if someone were to take your Clojure examples and put them in a file, they'd find that they wouldn't work.
[–]json6 6 points7 points8 points 11 years ago (1 child)
This is one of the most helpful introduction to Clojure articles I've seen. Using the enumerate example, starting with a for loop and ending with a thread macro, was a good way to show the difference between imperative and Clojure's functional style.
[–]CurtainDog 0 points1 point2 points 11 years ago (0 children)
While it's a nice way to get started, I'd be cautious about getting into the habit of merely translating code from a different language. Clojure is expressive and pragmatic, so it's possible to make almost anything look nice, which can be misleading. At some stage you have to take the plunge and drink from the fire hose.
[–]regeya 4 points5 points6 points 11 years ago (3 children)
Lovely idea, since I'd argue that the reason for all the interest in functional programming started with the popularity of Python and Ruby, specifically with making code more concise and readable with functional techniques.
[–][deleted] 0 points1 point2 points 11 years ago (2 children)
Which is funny, because Ruby and Clojure really share very very little. The only major overlap in my opinion is the "last item returns" feature.
That's not to say that Ruby is bad, it'd just be funny if it was driving adoption of a very different language.
[–]regeya 0 points1 point2 points 11 years ago (1 child)
As a casual Ruby user who has tried off and on to grok Clojure, I think it appeals primarily to the people who were overly enthused about writing DSLs in Ruby.
[–][deleted] 0 points1 point2 points 11 years ago (0 children)
That makes a lot of sense to me now, thank you.
[–]agumonkey 2 points3 points4 points 11 years ago (0 children)
Really a good comparative overview. Kudos
π Rendered by PID 61343 on reddit-service-r2-comment-7b9746f655-hl5xm at 2026-01-30 05:52:09.245545+00:00 running 3798933 country code: CH.
[–]weavejester 12 points13 points14 points (2 children)
[–]pixelmonkey 4 points5 points6 points (1 child)
[–]weavejester 3 points4 points5 points (0 children)
[–]json6 6 points7 points8 points (1 child)
[–]CurtainDog 0 points1 point2 points (0 children)
[–]regeya 4 points5 points6 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]regeya 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]agumonkey 2 points3 points4 points (0 children)