2010/5/21 Stefan Rohlfing <stefan.rohlf...@gmail.com> > This site http://paste.lisp.org/display/97057 shows various examples > of destructuring in Clojure ranging from basic to advanced. I managed > to follow the more basic examples, but then got quickly lost when I > looked at this one: > > (let [ [{a :a b :b c :c :as m :or {a 100 b 200}} [p q r & s] ] > [{:a 5 :c 6} [1 2 3 4 5]] ] [a b c m p q r s]) > > ; Result: [5 200 6 {:a 5, :c 6} 1 2 3 (4 5)] > > For example, I don't understand what [p q r & s] is doing here and how > {:a 5, :c 6} ends up in the result. > > Other examples such as the following are even more complicated and I > don't even know where to start: > > (let [ [ {:keys [a b c]} & [[d & e] {:keys [x y] :or {z 10000 y > 555}}]] > [ {:a 1 :b 2} "quux" {:x 1000 :y 999}]] > [a b c d e x y]) > > ;; Result: [1 2 nil \q (\u \u \x) 1000 999] > > This kind of advanced destructuring makes the code much less readable > for me. But this might just be because I am still new to Clojure. > > Therefore I would like to ask the following question: > -- Are the above examples used in 'real' code or do they mainly serve > as examples of what you can do with destructuring? In other words: Is > this idiomatic Clojure coding style? > > I would bet on: meant as examples for demonstrating the possible combinations, as well as the recursive nature of the patterns.
-- 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