This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-08
Channels
- # announcements (10)
- # beginners (53)
- # calva (22)
- # clj-kondo (21)
- # cljs-dev (1)
- # clojure (18)
- # clojure-europe (2)
- # clojure-filipino (1)
- # clojure-indonesia (1)
- # clojure-my (1)
- # clojure-seattle (6)
- # clojure-sg (1)
- # clojurescript (60)
- # code-reviews (3)
- # conjure (1)
- # cursive (1)
- # datomic (2)
- # figwheel-main (1)
- # fulcro (2)
- # gratitude (1)
- # honeysql (35)
- # lsp (6)
- # malli (5)
- # meander (11)
- # off-topic (27)
- # other-languages (3)
- # play-clj (1)
- # portal (31)
- # sql (13)
- # xtdb (5)
hi! when you have a let with a long list of values, however some of the values cannot be calculated for some reason (eg some special situation like missing / invalid data), how can you "short circuit" the let and return some other value? An exception would work, but that I don't like, is there something better?
Yes, an if
. You don't have to keep everything within the same let
bindings vector - you can split it into multiple nested let
s.
Maybe you can refactor things such that it's a reduce call and then you can use reduced
another short-circuity construct is some->
, although it's a bit more invasive (it forces you to use nil as the sentinel value)
@U2FRKM4TW @U45T93RA6 Yes I use both of these techniques, but I thought there is some more state-of-the-art 🙂 thanks to both of you
But I've seen https://github.com/adambard/failjure referred to a lot for these kind of scenarios. You could also use a macro, a let that checks if anything is reduced? and short-circuit returning the reduced value for example could work.
I want my api to return a json with strong names out of instinct but my coworker requests small names. What do you usually do in that situation?
hello, I begin clojure. but I am not clojure envirment setting. please help me ( it is not brew install/clojure/tools/clojure/ I have Homebrew installed on my MacbookPro)
Silly question, but where is the code for the clojure cli? I see a lot of the functionality in https://github.com/clojure/tools.deps.alpha but not the handling of CLI args like Stree
, so i figure i am missing something
@emccue I believe https://github.com/clojure/brew-install contains the code you're looking for
I'd like to change all the keywords in a map structure recursively. Does someone have an example spectre transform expression I can use as template? I've tried it like (transform [ALL MAP-KEYS] ...) but that did not work. Using (transform [MAP-KEYS] works, but not recursively)
I did this when I needed to process nested maps themselves. You can probably adapt it so it processes the keys instead of the maps. There should also be a helpful example or two in the Specter documentation.
(def MAP-NODES
(s/recursive-path [] p
(s/if-path map?
(s/continue-then-stay s/MAP-VALS p)
(s/if-path coll?
[s/ALL p]))))
(defn transform-maps [^Map m f]
(s/transform [MAP-NODES] f m))