On Jul 18, 2014, at 5:45 AM, Brian Craft <[email protected]> wrote:
> => (empty [:foo 5])
> []
> => (first (mapv identity {:foo 5}))
> [:foo 5]
> => (empty (first (mapv identity {:foo 5})))
> nil
=> (class (first (mapv identity {:foo 5})))
clojure.lang.MapEntry
=> (class (first (mapv (fn [[k v]] [k v]) {:foo 5})))
clojure.lang.PersistentVector
=> (empty (first (mapv (fn [[k v]] [k v]) {:foo 5})))
[]
by mapping identity over the map you're returning a vector of MapEntries (which
print/deconstruct like a two element array).
Cheers,
Bob
>
> What just happened there? Is this expected? In the second and third cases the
> type of the vector is clojure.lang.MapEntry, which I expect is the root of
> the behavior, but this seems very inconsistent. Is there a way to get the
> behavior one would expect? Should clojure.core/empty be avoided?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.