This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-22
Channels
- # babashka (36)
- # beginners (42)
- # calva (6)
- # chlorine-clover (25)
- # cider (31)
- # clara (5)
- # clj-kondo (55)
- # cljdoc (3)
- # cljs-dev (7)
- # cljsrn (3)
- # clojure (73)
- # clojure-brasil (6)
- # clojure-europe (8)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-norway (1)
- # clojure-spec (3)
- # clojure-sweden (4)
- # clojure-switzerland (2)
- # clojure-uk (29)
- # clojurescript (93)
- # conjure (21)
- # data-science (14)
- # datomic (19)
- # emacs (4)
- # exercism (3)
- # figwheel-main (38)
- # fulcro (38)
- # graalvm (42)
- # graphql (5)
- # jackdaw (3)
- # jobs (1)
- # joker (2)
- # lambdaisland (1)
- # leiningen (31)
- # malli (8)
- # meander (5)
- # off-topic (27)
- # pathom (2)
- # pedestal (28)
- # re-frame (25)
- # reagent (2)
- # reitit (11)
- # releases (3)
- # remote-jobs (1)
- # rum (1)
- # shadow-cljs (63)
- # spacemacs (17)
- # sql (1)
ahn, it is possible to add the implementation using extend
(extend Value
IMyInterface
{:isEmpty (fn [this] "ok")})
i also found this ticket https://clojure.atlassian.net/browse/CLJ-1625
Hello guys, I wrote a beginner-friendly walkthrough for getting a Clojure environment setup on Windows. Would love feedback, especially from learners who go through this to get their environment set up. https://www.notion.so/baibhavbista/Beginner-Clojure-Environment-Setup-Windows-36f70c16b9a7420da3cd797a3eb712fa
I quite like it. I'll give it a go once I'm on my Windows box. Btw do you mind if I take it as an inspiration to write similar guide but without WSL?
If you have any suggestions, feel free to comment in the doc itself or message me
is there a common pattern for dealing with legitimate nil return values, which might mean error in a context?
i found myself writing these quite often, but seems awkward
(if-let [ret (fn-with-legitimate-nil)]
ret
(throw (ex-info "too bad" {:type :mine})))
Funny thing I noticed, for simple cases (for ...)
is faster than (map ...)
.
(time (when-let [x (into [] (for [i (range 20000000)] (* i 2)))] (count x)))
"Elapsed time: 1716.010281 msecs"
=> 20000000
(time (when-let [x (into [] (map #(* % 2) (range 20000000)))] (count x)))
"Elapsed time: 2346.677037 msecs"
=> 20000000
(time (when-let [x (mapv #(* % 2) (range 20000000))] (count x)))
"Elapsed time: 1367.96382 msecs"
=> 20000000
So looks like it's both more legible (for newbies like me) and faster than intricate map
/`filter` combinations 🙂it will be faster with a transducer
hello, all! i am reading about transducers (https://bit.ly/3hPXdqk and https://bit.ly/2Ynwkm4) and i’d like to confirm something: when i comp
transducers is it correct to say that the operations are applied in the inverse order we usually have resulting from comp
? e.g. if i (comp str +)
then +
comes before str
but if i (comp (map inc) (filter odd?))
then inc
happens before odd?
.
if you are interested, there are other articles about transducers at https://vincent.404.taipei
The reason is a (map inc) returns a transducer. I would recommend watching the transducers talk from Rich Hickey from strangeloop to understand why.
In short: (map inc) returns a function which accept another function as input, but the process is done the inverse order. (You could make an analogue with middlewares if that helps).
cool, thanks! i was having a hard time trying to understand the texts because the results usually were different from my mental calculations. today i took some time to textually expand the composition and see what was going on and then wanted to confirm that it was indeed the ->
order instead of the usually expected comp
order. 🙂
If we're a little pedantic (sorry 😅), comp
works normally with transducers. Think middleware that transform HTTP request handlers. IF you take two of these A
and B
, comp
them and then transform a handler with that and use it. B
will be passed the handler, and the returned handler will be passed to A
, which itself returns a handler, which is used. Now, if both A
and B
are middleware that add headers a
and b
respectively, then when a request comes in, header a
gets added first and then b
gets added.
Hope this helps.
i’ll check the talk.
You might to watch the Clojure reducers talk as well (the one where he talks about apple pies). Which is a bit of the foundation I heard.
This one? https://youtu.be/IjB-IOwGrGE
Is there a reason why you do (conj a-vector value) but (cons value a-vector)? To preserve the order?
I do not know if the answer to that particular question can be found at this FAQ on argument order in Clojure core functions, but probably worth reading: https://clojure.org/guides/faq#arg_order
For cons
, the Scheme/Common Lisp function of the same name may have been an influence on arg order there.
yeah, that's my first hunch as well
conj
is a collection function and adds a value at the "appropriate" (fast) place for the specific collection type. cons
is a sequence function and always adds a value at the start of the sequence (which is always O(1)).
(conj [1 2 3] 4)
produces a vector. (cons 1 [2 3 4])
produces a sequence (technically a Cons
cell with 1
as the first element and (seq [2 3 4])
as the rest of the elements).
is seesaw still a lib which should be used today? I'm trying to go with a tutorial and ran into: "Tried to use insecure HTTP repository without TLS:" while running Leiningen to fetch the dependencies.
you shouldn't need any non-default repositories to use seesaw
@sroller What does lein version
report? Wondering if you have an old version of Leiningen that's still using http
links...
Leiningen 2.9.3 on Java 13.0.1 OpenJDK 64-Bit Server VM I read I should downgrade to 2.9.1 which wouldn't be as "picky" with http/https.
I just followed what was shown in https://gist.github.com/daveray/1441520
I'm using memoize ... but I get clojure.core$memoize$fn__6877@7f3d28c0 instead of a result