This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (1)
- # beginners (44)
- # calva (20)
- # cljs-dev (22)
- # cljsrn (5)
- # clojars (24)
- # clojure (33)
- # clojure-europe (36)
- # clojure-filipino (1)
- # clojure-indonesia (1)
- # clojure-my (1)
- # clojure-nl (2)
- # clojure-sg (2)
- # clojure-uk (8)
- # clojurescript (71)
- # code-reviews (21)
- # conjure (12)
- # crux (1)
- # cursive (43)
- # datahike (16)
- # datomic (5)
- # depstar (1)
- # graalvm (7)
- # honeysql (22)
- # jobs (2)
- # jobs-discuss (2)
- # kaocha (3)
- # luminus (2)
- # malli (2)
- # nrepl (17)
- # off-topic (45)
- # pathom (14)
- # re-frame (7)
- # remote-jobs (1)
- # sci (8)
- # shadow-cljs (33)
- # sql (14)
- # vim (46)
Thanks, I didn't know about arrayType. On the other hand Integer/TYPE need eval instead of resolve so not sure how I feel about that...
@vale could bring them into a closure at function definition, so it only runs once at program start
are there tipps, when one should use
defrecord or when they could be too much overhead or overcomplicate things?
Records are good when your map is closed (no extra or missing keys), and/or when you want to implement/extend a protocol
If someone wants to learn more about protocols/multimethods/etc. I found this booklet to be a really good summary of all the pros/cons and when you may want to use which: https://leanpub.com/clojurepolymorphism
I am using d3 in my project and it is possible to show result like this (first pic):
with this code (second and third pic):
I am a bit confused about the
-> syntax here. I know that is https://clojuredocs.org/clojure.core/-%3E
• (-> x & forms)
But I want to ask why using
Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc.
(d3/scaleLinear)the "x" above, not
d3/scaleLinearIs it reasonable to call a methods like
(d3/scaleLinear)without any given argument?
it's a function from d3 that takes no arguments. Whoever made that function made it so that it cannot take arguments. So it's pretty reasonable to call it that way.
In Clojure, the syntax
Or to be more precise, it is one good way to do so. There are others, but that is the most commonly used.
when working with threading macros and interleaving -first and -last based on the functions applied, is it more idiomatic to use the as-> macro, or wrap composed in anonymous functions to conform arg positioning?
See https://stuartsierra.com/tag/dos-and-donts — and the various posts about threading macros.
I'm trying to make my input function nicer by adding a prompt at the beginning, but it doesn't work like I'd expect. Here a minimal example:
When I try it in REPL (clj or lein repl) by calling it like this
(defn prompted-read [prompt] (print prompt) (read))
(prompted-read "Input: "), the prompt is shown only after I enter something. Is there a way to fix this?
@julian608 You need
dev=> (defn prompted-read [prompt] #_=> (print prompt) #_=> (flush) #_=> (read)) #'dev/prompted-read dev=> (prompted-read "Input: ") Input: 123 123 dev=>