This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-05
Channels
- # adventofcode (138)
- # announcements (1)
- # babashka (4)
- # beginners (71)
- # biff (2)
- # calva (7)
- # cider (20)
- # clj-kondo (4)
- # cljsrn (4)
- # clojure (36)
- # clojure-europe (37)
- # clojure-nl (2)
- # clojure-norway (27)
- # clojure-portugal (1)
- # clojure-uk (4)
- # clojurescript (8)
- # emacs (3)
- # graphql (1)
- # hugsql (4)
- # humbleui (6)
- # hyperfiddle (1)
- # jobs-discuss (18)
- # joyride (2)
- # malli (17)
- # meander (7)
- # membrane (8)
- # off-topic (16)
- # pathom (14)
- # portal (4)
- # rdf (36)
- # reitit (4)
- # releases (2)
- # remote-jobs (1)
- # scittle (15)
- # shadow-cljs (13)
- # tools-deps (40)
If I want to transform the same data in two ways, should I just run two operations? Or can I have a single operation with two "right hand sides"?
Sorry for the screenshot. I literally don't know how to copy and paste out of my remote editor.
@UG9CG9GDB Two seems right in this case. The first query is a join and the second is not. In the second you do not need to look for {:id ?team}
though.
(let [data {:people [{:name "greg", :team 1} {:name "jill" :team 2}]
:teams [{:id 1 :name "stars"} {:id 2 :name "fish"} {:id 3 :name "dogs"}]}
teams (:teams data)
people (:people data)
team-idx (into {} (map (juxt :id identity)) teams)]
{:players (m/search [people team-idx]
[(m/scan {:name ?name, :team ?team-id})
{?team-id {:name ?team}}]
{:name ?name :team ?team})
:teams (map :name teams)})
👍 1