We don't address this in the post, but adding :while conditions is quite a fun challenge.<p>This is the best I could come up with (in Emacs Lisp): <a href="https://gist.github.com/4356261" rel="nofollow">https://gist.github.com/4356261</a> . It's rather hacky :D<p>Darius Bacon (abecedarius) came up with a beautiful alternative formulation that handles :while conditions seamlessly. Here's my port of his idea into Emacs Lisp: <a href="https://gist.github.com/4380866" rel="nofollow">https://gist.github.com/4380866</a><p>I'd be very happy to see other versions :)
> Here's a question, though: If your language did not support list comprehensions, what would it take to add them? For a language like Ruby, you may have to dig into the language implementation itself.<p>No, not really:<p><a href="http://stackoverflow.com/questions/310426/list-comprehension-in-ruby" rel="nofollow">http://stackoverflow.com/questions/310426/list-comprehension...</a>
Gosh, if you had an extensible reader, you could do so much more... Oh wait, why don't we try it: <a href="http://lisp-univ-etc.blogspot.com/2013/01/real-list-comprehensions-in-lisp.html" rel="nofollow">http://lisp-univ-etc.blogspot.com/2013/01/real-list-comprehe...</a> ;)
I nice and somewhat related paper is "Simple and Efficient Compilation of List Comprehension in Common Lisp" by Mario Latendresse:<p><a href="http://www.iro.umontreal.ca/~latendre/publications/listCompFinal.pdf" rel="nofollow">http://www.iro.umontreal.ca/~latendre/publications/listCompF...</a>
Given that clojure is a dialect of lisp (the list processing language), it seems that list comprehensions should not be a remarkable achievement. Am i missing something?
This is very telling example of how differently Java people think.<p>First of all - ''this'' is NOT list comprehensions. Lisp has list comprehension, the sub-set of features that makes macros possible. Quote, back-quote, comma and grouping with parenthesis are parts of Lisp syntax to do it.<p>This is a meaningless generalization from a lisp programmer's perspective, just another macro.<p>Look at it carefully. This is the how confusion looks like. Thinking in terms of classes and methods prompts them to create artificial, unnecessary complications.<p>This is not hacking, this is exactly opposite.)