This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-03
Channels
- # announcements (4)
- # beginners (68)
- # boot (3)
- # business (20)
- # cider (39)
- # cljs-dev (7)
- # cljsjs (1)
- # cljsrn (12)
- # clojure (122)
- # clojure-brasil (2)
- # clojure-italy (7)
- # clojure-nl (5)
- # clojure-spec (60)
- # clojure-uk (41)
- # clojurescript (67)
- # cursive (7)
- # datomic (13)
- # emacs (6)
- # figwheel-main (18)
- # fulcro (40)
- # garden (3)
- # graphql (2)
- # hyperfiddle (4)
- # jobs-discuss (10)
- # lein-figwheel (5)
- # leiningen (12)
- # luminus (6)
- # mount (3)
- # off-topic (52)
- # portkey (2)
- # re-frame (1)
- # reagent (6)
- # reitit (24)
- # shadow-cljs (15)
- # sql (3)
- # tools-deps (12)
com.walmartlabs/cond-let 1.0.0 A micro library of a single macro, cond-let. cond-let acts like a cond, but adds :let terms that are followed by a binding form (like let). This allows conditional code to introduce new local symbols; the result is clearer, more linear code, that doesn't make a march for the right margin. Example:
(defn ^:private has-necessary-capabilities?
"Does the worker have all the capabilities that the job needs?"
[state worker-id task]
(cond-let
:let [job-id (:job-id task)]
(nil? job-id)
true
:let [capabilities (get-in state [:jobs job-id :clockwork/required-capabilities])]
(empty? capabilities)
true
:let [worker-capabilities (get-in state [:workers worker-id :capabilities])]
(empty? worker-capabilities)
false
:else
;; It's ok for the worker to have *more* capabilities than are specified.
;; For each required capability, we need an exact match.
(= (select-keys worker-capabilities (keys capabilities))
capabilities)))
https://github.com/walmartlabs/cond-let👍 28
how is this different from https://github.com/Engelberg/better-cond?
❤️ better cond, and this idea. I like how it stops the rightward drift. I do keep trying to sneak it into projects but usually get shut down because it's an additional dependency