Just curious:
(for [elem [1 2 3]
:let [elem+1 (inc elem)]]
elem+1)
=> (2 3 4)
but
(for [:let [elems [2 3 4]]
elem elems]
elem)
Syntax error macroexpanding for at (core.clj:12:1).
Can't pop empty vector
is there a reason behind this behaviour? I think :let here makes senseI think there is a JIRA issue for it somewhere, but not very high priority, maybe even rejected. Just use a surrounding let
in this case.
yep, this is what I am doing
Can anyone recommend a lib for managing datomic schema migrations with the client api library?
Does anybody have a better idea on how to write this?
Thanks everybody for the advices. More snippets will come here :)
I think it's just fine.
Personally, I'd split the condition and the assoc
into two lines.
Minor thing: I tend to use identical?
on keywords, but =
also works
Not cross-platform.
ClojureScript 1.10.773
cljs.user=> (def x :x)
#'cljs.user/x
cljs.user=> (identical? x :x)
false
I guess what I'm asking if it's ok to use cond->
to "simulate" something like
if (cond) return f(a) else a
This is the entire function in case it helps
@p-himik Since this is the #clojure identical?
is appropriate, in CLJS you use keyword-identical?
, good to be aware
IMO that's exactly what it was created for. It supports a bit more, but that's OK use only a part of this potential.
@borkdude Sure.
FWIW I use cond->
in such scenarios all the time. :)
You should probably be using the clojure.spec.alpha/invalid?
function though, the keyword may be an implementation detail
@borkdude makes sense, I'll change it
I'd use the shorter ::spec/invalid
form of the keyword (and split up the lines as @p-himik suggested). Otherwise LGTM 👍