x and y are destructured into the key and value of each map entry. Z is
nil.

The second example uses seq to convert the map into a sequence of map
entries and then it destructures the seq (not the map entries themselves).
The third example does destructure the map entries.

(let [[a b c] [1 2]] [a b c])
[1 2 nil]

Since map entries are treated like two element vectors, they get
destructured like that let does.
Since the third example is in a for, it does this for each map entry and
places the results in a sequence.

On Sat, 6 Jun 2015 12:24 gvim <gvi...@gmail.com> wrote:

> On 06/06/2015 05:01, Sean Corfield wrote:
> > Page 84 is where it shows that maps are a sequence of pairs.
> >
> > The destructuring in James's code is on vectors -- the pairs in the
> > sequence.
> >
> > Hope that helps?
> >
> > Sean
> >
>
> Page 84 describes the sequence abstraction in general but it's the
> implicit seq in for destructuring that threw me as I can't recall an
> example of it in any books I've read. I don't know what to make of this,
> for example:
>
> (seq {:a "aa" :b "bb" :c "cc"})
> ([:c "cc"] [:b "bb"] [:a "aa"])   ;; Fine so far
>
> (let [[x y z] (seq {:a "aa" :b "bb" :c "cc"})] [x y z])
> [[:c "cc"] [:b "bb"] [:a "aa"]]   ;; Consistent with first example above
>
> (for [[x y z] {:a "aa" :b "bb" :c "cc"}] [x y z])
> ([:c "cc" nil] [:b "bb" nil] [:a "aa" nil])    ;; WTF?
>
> Taken together these make no sense to me.
>
> gvim
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to