This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-07
Channels
- # announcements (1)
- # babashka (77)
- # beginners (219)
- # chlorine-clover (6)
- # cider (52)
- # clj-kondo (14)
- # cljdoc (5)
- # clojure (173)
- # clojure-europe (49)
- # clojure-finland (1)
- # clojure-germany (2)
- # clojure-italy (1)
- # clojure-nl (39)
- # clojure-sweden (4)
- # clojure-uk (51)
- # clojurescript (25)
- # code-reviews (9)
- # conjure (25)
- # data-science (2)
- # figwheel-main (6)
- # fulcro (74)
- # graalvm (1)
- # graphql (11)
- # jobs-discuss (17)
- # keechma (4)
- # lein-figwheel (4)
- # leiningen (1)
- # luminus (10)
- # malli (14)
- # mid-cities-meetup (2)
- # off-topic (28)
- # re-frame (5)
- # reagent (76)
- # reitit (30)
- # ring (7)
- # ring-swagger (1)
- # shadow-cljs (163)
- # spacemacs (11)
- # specter (2)
- # sql (43)
- # tools-deps (13)
- # vim (6)
- # yada (1)
Good morning 🙂
morning
Tomorrow evening we're looking at oz and visualisation tools to help make sense of data, no experience needed: https://www.meetup.com/Bristol-Clojurians/events/zdfnqrybcgblb/
is that happening remote? How are you doing it? we've been discussing remote options for lambda mcr atm as well :thinking_face:
we are using https://meet.jit.si/ currently seems ok, I want to test some others at work including http://screen.so
(def foo {:a nil, :b "bar"})
user=> (into {} (map (fn [[k v]] (if (nil? v) {k ""} {k v}))) foo)
{:a "", :b "bar"}
you can give that a bit of syntactic sugar with medley
(medley.core/map-vals #(or % "") foo)
mind you I've ALOT of code that I think that about
and clojure core is pretty busy already
i quite like (->> foo (map (fn [[k v]] [k (or v "")])) (into {}))
@cfeckardt yes, with a slight change (reduce-kv (fn [m k v] (assoc m k (or v ""))) {} foo)
or even (->> (for [[k v] foo] [k (or v "")]) (into {}))
all very good choices, but I'm going to stick with core in this instance, no need to pull in medley
I'm still trying to get my head around for
. I've used for
in the traditional sense, i.e., looping
for
is quite nifty - i like the cartesian-product thing:
(for [a [1 2 3] b [:x :y :z]] [a b])
=> ([1 :x] [1 :y] [1 :z] [2 :x] [2 :y] [2 :z] [3 :x] [3 :y] [3 :z])
I often think zipmap reads quite well for this sort of thing — though not as efficient as reduce-kv
due to iterating the k/v’s twice
(zipmap (keys foo) (->> foo vals (map #(or % ""))))
for
is great
is there a 'for' in Python which is like the clojure for
?
its so different to the Java for
that I never really consider it
why use 'for' when you can use 'map'
Because it’s really good for doing nested iterations, cartesian products, and also the :when
:while
:let
extensions make more complex stuff easier to read; and prevent excessive indentation.
Compare the nested cases of:
(for [x (range 10)
y (range 20 30)]
[x y])
or:
(for [x (range 10)]
(for [y (range 20 30)]
[x y]))
To the map equivalents:
(mapcat (fn [x]
(map (fn [y]
[x y])
(range 20 30)))
(range 10))
(map (fn [x]
(map (fn [y] [x y]) (range 20 30)))
(range 10))
(appologies for indentation)
and you’ll see that in the for
case the bindings all align, and the result is cleanly separated from the mechanics of iteration.
It’s a macro, so when you need a function map
can obviously, or in the thread-last chaining cases.unless you are using the funky stuff
i vacillate - map
is clearly better when you've got a pipeline, but sometimes for
just seems cleaner to me
double question:
what OSX are people currently on
what jdk are people currently using
kind of thinking of just jumping to 11 since I'm bootstrapping a new laptop
macOS 10.12.6 -- because I'm tired of Apple breaking my dev env every time I upgrade (and I'm switching to Windows with my next machine)
Adopt OpenJDK 11 in production. Standard OpenJDK 14 locally for testing (and Adopt OpenJDK 8 and 11 as well for matrix testing).
how are you managing adopt openjdk?
I assume not brew, just manually
I’m not not Mac, instead Arch Linux. We use Linux almostly exclusively at work. We run OpenJDK 8 and 11 (mostly 11 in Production now)
I was using adoptopenjdk8 on my lenovo so I'll push up to 11 LTS on this new machine
thanks for the help gang 👍
@alex.lynham I just set JAVA_HOME
to whichever one I want to use. And I have convenient env vars for the others in my .profile
file:
export OPENJDK8_HOME=/Developer/jdk8u232-b09/Contents/Home
export OPENJDK11_HOME=/Developer/jdk-11.0.5+10/Contents/Home
export OPENJDK14_HOME=/Developer/jdk-14.jdk/Contents/Home
export JAVA_HOME=$OPENJDK14_HOME
(looks like I removed the Zulu JDK 8 version at some point -- that was convenient for REBL)Ah okay that makes sense
I did use brew originally, then jenv
@alex.lynham…