This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-14
Channels
- # announcements (9)
- # beginners (49)
- # calva (26)
- # cider (6)
- # clj-kondo (17)
- # cljsjs (1)
- # cljsrn (2)
- # clojure (72)
- # clojure-europe (5)
- # clojure-france (8)
- # clojure-greece (1)
- # clojure-italy (5)
- # clojure-nl (9)
- # clojure-spec (49)
- # clojure-uk (17)
- # clojuredesign-podcast (13)
- # clojurescript (137)
- # cursive (15)
- # data-science (1)
- # datomic (55)
- # duct (2)
- # emacs (5)
- # figwheel-main (11)
- # fulcro (11)
- # graphql (1)
- # hoplon (1)
- # instaparse (1)
- # jobs (12)
- # jobs-rus (1)
- # leiningen (1)
- # nrepl (34)
- # nyc (2)
- # off-topic (1)
- # onyx (1)
- # pedestal (1)
- # re-frame (6)
- # reitit (3)
- # remote-jobs (1)
- # shadow-cljs (196)
- # sim-testing (1)
- # spacemacs (9)
- # sql (1)
- # vim (70)
- # xtdb (31)
@lockdown- To "unqualify" a keyword? No, that seems a reasonable way to do it.
When using the ->>
macro, how to take the result of the last line (which will be a seq
of some sort) and operate on each part. In other words, how can i accomplish
`(->>
`(->> (returns-seq) (for [x ,,,]))`
I am looking into the as->
macro but I am having trouble understanding how it works
@mbbailey96 start your pipeline with ->
(-> expr
(->> your pipeline here)
(as-> s (for [x s] ,,,)))
@seancorfield thank you!
Hello all, how to I pass operator for a filter? I know that is wrong, but how is the correct way to do this?
(defn- todos-alarmes-filtrados-por-chave [endereco chave valor & {:keys [operador] :or {operador .contains}}]
(->> (alarme/todos-alarmes endereco)
(filter #(not (nil? (chave %))))
(filter (apply operador (chave %) valor))))
Tiny style point. You can use remove
instead of filtering with complement of predicate
(filter #(not (nil? (chave %))))
is same as (remove #(nil? (chave %)))
is same as (remove (comp nil? chave))
What is operador
here? Not quite sure what the problem is.
When using protocols, do you usually use them for your SPI's? I've started to get the habit to define protocols for all my SPI actions (save user-information to a database etc), since it is easy to create a "FakeStorage"-implementation.
@fabrao Not sure what your question is here? What doesn't work about that code?
@jarvinenemil Perhaps you are over-using protocols?
Oh, @fabrao you can't use Java methods directly you need to wrap them in Clojure functions: #(.contains %1 %2)
Yeah @seancorfield i still get the notion that I am thinking too much in Java-interface terms when using Protocols in Clojure (sometimes).
There's no point in using protocols unless you have multiple implementations for them, IMO.
@fabrao Something like that, yes
@seancorfield currently I have two record implementations for each protocol, one implementation that runs in the prod-environment and one that is used in tests
Mmm, still sounds a bit unnecessary...
That's a very OO way of dealing with mocking for tests.
Indeed, I need to find another way of dealing with the mocking for tests. Thinking of using with-redefs instead
(I did read that one should avoid that though)..
@jarvinenemil that really depends on context. It’s fine for most use cases.
@U38004EG7 multithreaded tests comes into mind for me
If you can refactor to pure data and function arguments, you'll probably be better off...
I will try some ideas, in my current implementations all state is defined as function arguments. I just need to remove some records 🙂
I found this comment section quite interesting: (Protocols and records): https://www.reddit.com/r/Clojure/comments/42nkkw/how_i_use_component/
it's a special reader macro that says to skip the next form read. So here SOMETHING will be read (as a symbol) and thrown away
one useful variant:
user=> {:a 0 #_#_ :b 1 :c 2}
{:a 0, :c 2}
inline comment of key/value pair by stacking #_ inside a hash-map(maybe that only works if you consciously adapt the idiom, but #_#_
is pretty unmistakable once you learn to recognize it)
right
another variant I like - sadly cljfmt doesn't like it though:
#_
(defn broken-on-load
"commented out for now, but will uncomment when it doesn't break the namespace"
[]
...)
the advantage is in git it doesn't add whitespace diffs
and it's less invasive than (comment ...)
which would do the same thing (and imposes indentation based on standard paren nesting rules, where the reader macro doesn't)