RE: doall

2018-05-16 Thread Sean Corfield
(zipmap inviteds (repeat 1))

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood


From: clojure@googlegroups.com  on behalf of Renata 
Soares 
Sent: Wednesday, May 16, 2018 10:08:58 AM
To: Clojure
Subject: doall

Hello,

I have this vec called inviteds [:2 :4]

and I want to produce something like (hash-map :2 1, :4 1)

(doall (map #(hash-map % 1) inviteds))

but returns ({:2 1} {:4 1})

How can I produce the same result as (hash-map :2 1, :4 1) with doall (or other 
similar function)?

Thanks!

--
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.


Re: doall

2018-05-16 Thread Justin Smith
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 <
mauricio.aldaz...@gmail.com> 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 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.


Re: doall

2018-05-16 Thread Mauricio Aldazosa
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 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.


Re: doall

2018-05-16 Thread Colin Yates
If you have a sequence of maps then merge is your friend:

(def maps = [{:2 1} {:4 1}])
(apply merge maps)

To create convert a sequence into a map whose key is always 1:
(into {} (map (fn [x] [x 1]) [:2 :4]))  

HTH

> On 16 May 2018, at 18:08, Renata Soares  wrote:
> 
> Hello,
> 
> I have this vec called inviteds [:2 :4]
> 
> and I want to produce something like (hash-map :2 1, :4 1)
> 
> (doall (map #(hash-map % 1) inviteds))
> 
> but returns ({:2 1} {:4 1})
> 
> How can I produce the same result as (hash-map :2 1, :4 1) with doall (or 
> other similar function)?
> 
> Thanks!
> 
> -- 
> 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.


Re: doall

2018-05-16 Thread Laurens Van Houtven
Hi Renada,


The magic function you're looking for is called "frequencies":
https://clojuredocs.org/clojure.core/frequencies

You could look at its implementation if you want to know how to implement
this :)


lvh

On Wed, May 16, 2018 at 12:08 PM, Renata Soares 
wrote:

> Hello,
>
> I have this vec called *inviteds* [:2 :4]
>
> and I want to produce something like (hash-map :2 1, :4 1)
>
> (doall (map #(hash-map % 1) *inviteds*))
>
> but returns ({:2 1} {:4 1})
>
> How can I produce the same result as (hash-map :2 1, :4 1) with doall (or
> other similar function)?
>
> Thanks!
>
> --
> 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.


doall

2018-05-16 Thread Renata Soares
Hello,

I have this vec called *inviteds* [:2 :4]

and I want to produce something like (hash-map :2 1, :4 1)

(doall (map #(hash-map % 1) *inviteds*))

but returns ({:2 1} {:4 1})

How can I produce the same result as (hash-map :2 1, :4 1) with doall (or 
other similar function)?

Thanks!

-- 
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.


Windows Cygwin lein repl

2018-05-16 Thread skf . phoenix
Hi,

I don't know if this is off topic, so I apologize in advance.

I have upgraded to the Leiningen 2.8.1 and since then I have not been able 
to open a repl.

This is on Windows, behind a proxy, being launched from in Cygwin.  Where 
as Leiningen 2.7.1 repl works from when launched in Windows Command Prompt.

The details of this so far can be seen 
here:  https://github.com/technomancy/leiningen/issues/2423

Could someone suggest a diagnostic approach?  Or better yet a fix :)


--
Kind regards

Stephen.

-- 
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.