Fork me on GitHub
Trung Dinh03:08:57

hi, wrapping my head around destructuring… not sure how to get all :val in a vector of maps, e.g (def maps-in-vector [{:name "n1" :val 1} {:name "n2" :val 2} {:name "n3" :val 3}]) I’ve looked through some resources (such as , or Russ Olsen’s book, but haven’t found yet…, can anyone please help? Thanks


so something like this will work explicitly for a 3-element vector:

  [[{val-1 :val} {val-2 :val} {val-3 :val}]]
  (println val-1 val-2 val-3))
but if you're looking for a more general solution where you'd have some destructured vals that was automatically [1 2 3] I don't think that's possible

Trung Dinh04:08:40

Thanks, I’m actually looking for the general solution, guess I’ll have to build the vector with reduce first then….


if it doesn't have to be in the destructure I think (mapv :val maps-in-vector) will give you the actual values you want

👍 9

Can you explain what you’re trying to do?

Trung Dinh04:08:34

I’m just trying possible ways on how destructuring work 🙂


Do you know how to destructure a single map?


Is there a way to comma-format numbers with specifiers in clojurescript? In Clojure I'd use (format "%,d" num) but trying that with the goog.string library doesn't work. I'd have thought this would be easy to google, but no luck.


Hi, closure library provides quite comprehensive formatters for various use-cases. Check out


It’s not trivial to use but hope you get the idea

cljs.user> (require '[goog.i18n.NumberFormat])
cljs.user> (require '[goog.i18n.NumberFormatSymbols_fi])
cljs.user> (def fi goog.i18n.NumberFormatSymbols_fi)
cljs.user> (set! js/goog.i18n.NumberFormatSymbols fi)
cljs.user> (def fmt (new goog.i18n.NumberFormat goog.i18n.NumberFormat.Format.CURRENCY))
cljs.user> (.format fmt 13.20)
"13,20 €"


That looks great, thanks very much! Surprised that doesn't come out the box, I would've thought it's a very common use case


is there an obvious reason why (or refresh-all) would not reload changed files when i'm running from within a docker container? do i have to own the files as well (my uid is different in the container)


I've run into this when I had to run Docker through a virtual machine. It doesn't pick up that the files changed inside the container. However IIRC this was only for the refresh and not refresh-all


When I run my code in clj -repl my code works, but when I put it in a file I get all sorts of errors that I do not understand this is my code


In other words how do i copy working code from repl to a file?


I'm doing some katas to begin my clojure journey. I'm getting an error about being unable to take the value of a macro from the following code.


(ns multiples) (defn divisible-by? [x d] true? (= (mod x d) 0)) (defn condition? [n] or (divisble-by? n 3) (divisible-by n 5)) (defn solution [number] reduce + (filter condition? (range number)))


@tylertracey09 Parentheses are very important in Clojure: they indicate function calls, for example, and you're missing those around most of your calls.


(ns multiples)

(defn divisible-by? [x d]
  (= (mod x d) 0)) ; don't need true? here since = already returns boolean

(defn condition? [n]
  (or (divisible-by? n 3) (divisible-by? n 5))) ; need parens around use of (or ...)

(defn solution [number]
  (reduce + (filter condition? (range number)))) ; need parens around use of (reduce ...)

👍 3

@ruby.object Folks won't really be able to help you unless you can explain what exactly you tried and what errors you are seeing.


Looking at that repo, it's very hard to know what you're actually attempting to do.


If you want to look at deps.edn-based Ring app, this may help


I was trying to move the code that works in clj -repl to a file in the tasks folder and can be run with clj -A;tasks without the need to write a sequence of command in terminal repl


btw I was looking @seancorfield tutorials about using deps.edn instead of using lein.


Thanks, Sean


Does anyone use Calva with VS Code?


I'm trying to figure out if there's a way to do something like evaluate the expression under the cursor


Or perhaps open the current file in a repl quickly


ctrl+alt+c,enter will load the current file in the repl, ctrl+alt+c,v will eval the current form to repl


ctrl+enter will also eval current form


alt+enter will evaluate the top-level form


@tylertracey09 The #calva channel will be a great place for you to get in depth help with that combo.