On Tue, Jul 7, 2009 at 6:08 AM, Roman Roelofsen < roman.roelof...@googlemail.com> wrote:
> > Hi all! Hello! Welcome to the group. <snip> * Syntax * > > I never used a LISP-like language before and I can't read the clojure > code as fluent as code from different languages. Take for example this > scala snippet: > > (0 until 100) map (_ * 2) filter (_ % 3 == 0) > > I can easily read this line from left to right (just like english) and > instantly see whats going on. By contrast, I have to read the clojure > version a couple of times to understand it: > > (filter #(= 0 (rem % 3)) (map #(* 2 %) (range 100))) > > Is this just a matter of pratice? Do you find it easy to read the > clojure version? I find it easier to read Clojure code when I don't have everything on one line. In other languages I've been able to put everything on one line and survive, but in CL and Clojure it has always read better on multiple lines. For instance, the code you provided could be written like: (filter #(= 0 (rem % 3)) (map #(* 2 %) (range 100))) Then the parts of the code and their relations can be easier to find. Now I can easily tell that whatever comes out of the call to map is being filtered - without caring about what is 'under' the call to map. This ability to ignore the parts that are 'inside' some deeper code has helped me in reading Clojure code. <large snip> > > Sorry for the long posting and thanks a lot for reading it ;-) I don't mind the long posting. You had everything sectioned out nicely. Cheers, > > Roman Good luck with learning Clojure, I hope you continue to enjoy it.. -Rich --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---