This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-25
Channels
- # babashka (31)
- # beginners (38)
- # biff (1)
- # calva (10)
- # clj-kondo (10)
- # clj-otel (9)
- # clojure (9)
- # clojure-europe (4)
- # clojure-norway (4)
- # clojurescript (26)
- # cursive (2)
- # datahike (3)
- # datomic (4)
- # emacs (6)
- # inf-clojure (2)
- # missionary (11)
- # nbb (3)
- # off-topic (9)
- # portal (17)
- # re-frame (16)
- # reagent (1)
- # releases (3)
- # shadow-cljs (5)
- # tools-build (17)
- # tools-deps (2)
- # xtdb (6)
Hello, im struggling with -> and ->> can you help me: do we need to use -> or ->> in this example, and how would do this 🙂
(defn set-p [im i j]
(set-pixel (+ i (first offset)) (+ j (last offset))
(apply color (map (fn [c] (+ c 10)) (rgba (get-pixel im i j))))))
(defn set-p [im i j] (->> (get-pixel im i j) rgba (map (fn [c] (+ c 10))) (apply color) (set-pixel (+ i (first offset)) (+ j (last offset)))))
wow, thank you very much. It is working :0
You might want to see if your editor can be made to do the refactoring for you. Then you can toggle backward and forward. NB automated refactoring might give you a thread starting with just j as the first form, which can be passed to (get-pixed im i) in a thread-last but is obviously not as clear.
Hi! I am going through the "Web development with Clojure" book. I am using VsCode and I also have clj-kondo. Kondo complains about the following code: (defn handler [request-map] {:status 200 :headers {"Content-Type" "text/html"} :body (str "<html><body> your IP is: " (:remote-addr request-map) "</body></html>")}) I get a Mismatched bracket: found an opening { and a closing ) .... Is there something I can configure in Kondo to make it go away ? Thx!
also you can use triple backticks to post code formatted text
(defn handler [request-map]
{:status 200 :headers {"Content-Type" "text/html"}
:body (str "<html><body> your IP is: "
(:remote-addr request-map)
"</body></html>")})
Will do.
i'm wondering if you copied it and maybe there are some weird {
characters that aren't what yo uthink they are
I typed it and I also copied it and the result was the same. I had no error when evaluating it. That is why I assumed that it's a configuration issue.
Thx for the Info!
Did you use clojure-lsp?
Not that I am aware of
Can you maybe post the while file as an attachment here? There may be something weird in your file
This is the file:
For completeness: I am using VsCodium Version. 1.68.1
It's not such a big issue, for me at least. I just got confused 😄
Does the error persist when you restart it? And can you maybe try VSCode too, just to check?
Yes for me, it's editor side issue. If you run clj-kondo --lint src
via cli directly, you shouldn't have theses errors.
Ok, good to know.
FYI Seems Calva use clojure-lsp under the hood and clojure-lsp use is proper clj-kondo version. https://calva.io/clojure-lsp/ Myself I'm not using VSCode but Emacs with clojure-lsp and I experience sometimes these sort of lint errors when modifying function & co. I have to manually refresh the file/buffer to get the "real" linter information.
Thx for the Info! Now that I know this, I will just restart if something is fishy 🙂.
You probably should not use the clj-kondo extension since you are using clojure-lsp and get clj-kondo linting that way.
Does it make sense to look into Luminus or should I skip it and go for Kit?
For understanding the overall concepts of a server-side or 'full-stack' application in Clojure, it won't make a lot of difference However, Clojure projects and libraries have been moving to a more data centric implementation It's the implementation of these concept, the config and libraries used that to me are the difference between kit and Luminus. I would suggest Kit because it has more of this data centric approach. Reitit is a really nice way of defining routes (and can use ring handlers & middleware server side),and Integrant (although a bit of a learning curve) is very useful when a system has multiple components (http server, logging, dn connection, routing, etc. If you want the very basics, then take a look at https://practical.li/clojure-web-services/
Tank very much for the information! I appreciate you taking the time to explain the difference 🙂.
Is there a way to do something like partition-by
but where it creates a new group whenever the value is true, rather than when it changes? I've written a reduce
version, but I assume I'm missing a trick with partition-by
or another function
(->> [1 3 2 4 1 2 3]
(reduce
(fn [acc n]
(if (odd? n)
(conj acc [n])
(update
acc
(dec (count acc))
#((fnil conj []) % n))))
[]))
;; => [[1] [3 2 4] [1 2] [3]]
Try this:
(->> [1 3 2 4 1 2 3]
(partition-by (let [v (atom 0)]
#(if (odd? %)
(swap! v inc)
@v))))
=> ((1) (3 2 4) (1 2) (3))