This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-11
Channels
- # aleph (38)
- # announcements (6)
- # aws (1)
- # beginners (47)
- # calva (21)
- # cider (47)
- # cljs-dev (18)
- # clojure (40)
- # clojure-europe (7)
- # clojure-india (2)
- # clojure-italy (9)
- # clojure-nl (11)
- # clojure-norway (2)
- # clojure-sanfrancisco (1)
- # clojure-spec (17)
- # clojure-sweden (2)
- # clojure-uk (73)
- # clojurescript (10)
- # cursive (6)
- # datascript (12)
- # datavis (2)
- # defnpodcast (1)
- # duct (5)
- # emacs (36)
- # figwheel (2)
- # figwheel-main (10)
- # juxt (12)
- # leiningen (1)
- # midje (1)
- # nrepl (9)
- # off-topic (25)
- # pedestal (3)
- # portkey (3)
- # quil (2)
- # re-frame (45)
- # reagent (1)
- # ring (3)
- # ring-swagger (36)
- # rum (1)
- # shadow-cljs (48)
- # spacemacs (1)
- # speculative (50)
- # testing (2)
- # tools-deps (27)
- # yada (4)
((:close foo))
- how to write instead something like (-> (:close foo) ())
. I want to make it more readable, but I confused myself 🙂
You could do
(let [{:keys [close]} foo]
(close))
Why complicate this? It's calling the function that is returned by the :close
key. It's perfectly fine the way it is.
Ah, nvm. Didn't see the text that followed.
would this look more readable ? (invoke (:close foo))
?
@kwladyka maybe something like this?
(def foo {:bar #(println "nice")})
((-> foo (:bar)))
I tend to not use ->
unless it's more nested, one level usually just do ((:bar foo))
directly, but not sure that's idomatic
hey all, I started using defmulti/defmethod. Is it intended that you can't use Destructuring with Keyword-arguments in defmethod?
dispatch function (:type) is applied to three arguments. You should either rewrite youy dispatch function for it to be ready to accept vavarg or get rid of vararg and accept just one map
oh, didn't know that the dispatch-fn will be applied to every arg and not only the first.. Thanks. 👍 I'll use only one map
Clojure 1.10.0
user=> (take 2 [])
()
user=> (take-last 2 [])
nil
Is it likely that a patch would be accepted to modify take-last
to return an empty seq when given an empty seq?in general, I would expect any code that uses the result of either of these to work in either case
expectation for sequence functions should be that take something seqable and return something seqable
with Spec, if I have (s/def my-map (s/keys :req [a b]))
where a
& b
are (s/coll-of something)
, how can I say I want a
& b
to have the same length ?
(not using :count
- I don't care how long they are, only that they're the same length)
write a function that checks that and s/and it to your spec
@alexmiller much easier than I thought! thankyou
you can pretty much write a predicate to check any arbitrary property of data and all predicates are specs
it's a while since I used Spec, it's all coming back now
Hijacking a question here, can you specify in an fspec
what the side-effects of a function may be. That would basically entail doing something before the fn runs, and after.
For example, I have a swap-vals!
kinda thing for redis, I would very much like to assert that the first result you get is the state prior to the function being ran.
:thinking_face: :thinking_face: :thinking_face: well... nothing stops you from doing effects in your predicates
but, maybe fine? I wouldn't reach out to your redis instance each time the fn is called
Right, its an obvious development-only kinda deal right
maybe you could have a custom instrumentation that swaps an atom with the before state, then compares in the :ret
Its just that I don’t think you have a hook that is ran before the function is called
(this is obviously more a code-golfing thing than actually useful, please don’t hate me)
How do I invite a bot to a channel that logs conversations to https://clojurians-log.clojureverse.org/
Invite @logbot to your channel
there is a web page somewhere that lists api's to third party clojure libraries...help?
http://cljdoc.org <-- found it 🙂
Also https://crossclj.info/ if you're searching for libraries to solve a specific task.