Fork me on GitHub
#beginners
<
2021-12-26
>
Jacob Rosenzweig00:12:44

Just found this wicked AoC Day 1 solution:

(defn inccount [input]
  (count (filter true? (map < input (next input)))))
I did not know that you can add multiple collections to a map function.

🙌 1
Dmitrii Pisarenko01:12:21

Hello! Imagine I have a vector like

[:start-process "some-process-id" :as "process-instance-id"]
and want to extract "some-process-id" and "process-instance-id" from it (I don't care about the other elements and at the time when I'm doing this I am sure that the vector has exactly this structure.) What is the right way to do it? Specifically, can I tell destructuring to ignore parts of the vector? Something like this (`_`means that I am not interested in that value):
[[_ process-id _ instance-id] [:start-process "some-process-id" :as "process-instance-id"]]

Jens13:12:26

I have several functions where the same spec fdef is used. Is there a way to share the fdef between the functions and avoid the code duplication?

Alex Miller (Clojure team)13:12:41

You can use s/def instead and refer to the same function spec (by name or var)

Alex Miller (Clojure team)13:12:24

fdef is really just s/def with symbol as function name instead of a keyword

Muhammad Hamza Chippa16:12:03

Hello I am trying to work with the reagent and created a simple html component, the problem I am getting when I am trying to define the reagent/atom inside the let scope it is not working but when I am trying to define the atom outside the function it is working fine, how can I make the reagent/atom work properly define in the let scope ?

(defn click-count []
  (let [click-count (reagent/atom 0)]
    [:div
   "The atom " [:code "click-count"] " has value: "
   @click-count ". "
   [:input {:type "button" :value "Click me!"
            :on-click #(swap! click-count inc)}]]
  ))