as an aside, :1 etc. are bad keywords (accepted by some readers and not
others, technically not valid according to the docs), and usually the
presence of keywords like that indicates over-eager keywordizing of json
input, or a misunderstanding of clojure hash-maps

On Wed, May 16, 2018 at 12:38 PM Mauricio Aldazosa <
[email protected]> wrote:

> Hi Renata,
>
> The problem with your code is that it is using *map* at the top level,
> which is a function that returns a lazy sequence. You are asking clojure to
> do something like:
>
> *Take each number n in inviteds and create a sequence of hash maps, where
> each hash map has n as a key and 1 as it's value.*
>
> But what you really want is a function at the top level that returns a
> hash map. As Colin shows, you can use *into* (here is a slightly
> different way than the one he used):
>
> *Take each number in inviteds and create a sequence of pairs. Each pair
> should have the number as it's first value, and 1 as the second. Then take
> those pairs, and "pour" them into a hash map.*
>
> (->> inviteds
>      (map (fn [number] (vector number 1)))
>      (into {}))
>
> You could also do it via *reduce*:
>
> *Start with an empty hash map, then assoc each number in inviteds with 1
> as it's value*:
>
> (reduce (fn [m number] (assoc m number 1))
>         {}
>         inviteds)
>
> Cheers,
> Mauricio
>
> --
> 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.

Reply via email to