Fork me on GitHub
#beginners
<
2015-07-01
>
tap03:07:09

what’s a better way to do this?

(let [users [{:id 1 :name "Michael"}
             {:id 2 :name "Steve"}
             {:id 3 :name "Ben"}
             {:id 4 :name "Michael"}]]
  (->> users 
       (group-by :name)
       (map (juxt key #(->> (val %) 
                            (map :id) 
                            (set) 
                            (hash-map :ids))))
       (into {})))
After group-by, is there a way to map the values without turning the whole thing to sequence and have to convert back to a map again?

Alex Miller (Clojure team)03:07:51

there's no way to avoid building a new map. But could use reduce-kv or into with a map transducer to avoid the intermediate sequence.

tap03:07:19

got it. thanks @alexmiller

chadhs04:07:31

i feel like such a newb guys, i’m looking at the ClojureScript QuickStart and can’t get cljs.jar to build the hello world example

chadhs04:07:02

java -cp cljs.jar:src clojure.main build.clj                                                                     
Error: Could not find or load main class clojure.main

chadhs04:07:09

doh; the cljs.jar file was an incomplete download

xhh04:07:59

@chadhs: you might already know it, but using boot or lein would be much easier to run clj program or a repl to play with clojure code

chadhs04:07:34

@xhh oh definitely and thank you. the quickstart just has you grab the stand alone for a quick tour

chadhs04:07:42

the first real tutorial uses lein

chadhs04:07:48

so excited for that

chadhs04:07:33

my evil plan is to rewrite a frontend for a Django site that is currently backbone/coffeescript/icanhazjs in ClojureScript. crazy?

xhh04:07:25

indeed, but not evil as long as it works out 😈

chadhs04:07:06

haha, true

tupaja20:07:13

Hi, I'm wondering - what's the best way to introduce websockets connection in a ring app? I'm looking for a solution which doesn't require writing client side in clojurescript and would provide connection multiplexing (like channels in http://socket.io or elixir's phoenix framework). I'm aware of solutions like sente or aleph, but as stated before - am looking for a pure JS solution on the client side. Thanks!