This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-30
Channels
- # adventofcode (4)
- # aleph (1)
- # announcements (7)
- # aws (10)
- # babashka (23)
- # beginners (23)
- # calva (20)
- # chlorine-clover (13)
- # cider (17)
- # clj-kondo (13)
- # cljfx (9)
- # cljsrn (9)
- # clojure (98)
- # clojure-australia (1)
- # clojure-dev (15)
- # clojure-europe (127)
- # clojure-nl (4)
- # clojure-sanfrancisco (3)
- # clojure-uk (98)
- # clojurescript (25)
- # community-development (8)
- # core-async (15)
- # cryogen (9)
- # cursive (7)
- # data-science (1)
- # datascript (5)
- # datomic (3)
- # devcards (2)
- # fulcro (5)
- # graalvm (1)
- # helix (8)
- # jackdaw (1)
- # jobs (5)
- # kaocha (17)
- # malli (5)
- # meander (5)
- # off-topic (37)
- # pathom (33)
- # pedestal (3)
- # re-frame (12)
- # reitit (1)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (6)
- # testing (1)
- # vim (6)
- # vrac (5)
how could I find all the keywords in an arbitrarily nested data structure (which has sets, arrays, etc inside)?
I have problems with this in clojurescript when the map contains strings, because:
(seq "a")
evaluates to ("a")
something like this
(let [a (atom [])]
(clojure.walk/prewalk #(if (keyword? %) (do (swap! a conj %) %) %) [#{{:a '(1 :b)}}])
@a)
;; => [:a :b]
seems like a straightforward way to what I understand your first question to be, however I don't understand your addition to it.
there is probably some nicer way to do it though(->> [#{{:a '(1 :b)} :c} :d]
(tree-seq seqable? identity)
(filter keyword?))
;; => (:a :b :c :d)
is another
basically you'll want something like walk or tree-seqI have problems with this in clojurescript when the map contains strings, because:
(seq "a")
evaluates to ("a")
Hi, is there a good one-liner to get this result? Someone see another better solution? More idiomatic and/or concise?
(->> [1 2 3 4 5] (filter even?) (mapv #(* % 10)))
;; => [20 40]
your code is fine!
transducer version:
(into [] (comp (filter even?) (map #(* 10 %))) [1 2 3 4 5])
Perfect, thanks for these solutions!@U01EFUL1A8M
I was just thinking of a version with comp, I like it.
The comp version produces a transducer, which evaluates eagerly. See: https://clojure.org/reference/transducers
Hello, i need to create simple API web server for my vue.js App. The server only need auth & crud stuff. I don't really understand about web security. So is it recommended to use only reitit and add some security stuff (via library if there is any, or implement myself (hopefully there's some resources i could read)) or use a framework such as luminus/pedestal?
Hi @raefaldhiamartya First of all, you can watch this video https://www.youtube.com/watch?v=CBL59w7fXw4 It's not recent so the libraries (friend, buddy, etc) have evolued but the main security concerns are still relevant. I recommend reading also this posts https://purelyfunctional.tv/article/clojure-web-security/
You"re welcome! If you using Reitit Ring so I recommanded to adding this Ring middleware: https://github.com/ring-clojure/ring-defaults > This library attempts to automate the process, by providing sensible and secure default configurations of Ring middleware for both websites and HTTP APIs.
@raefaldhiamartya Last but no least, @UGJ8075QQ just post the third part of video tutorials series about how to using Buddy auth library. https://youtu.be/FcxO5VCPLi4
You"re welcome! If you using Reitit Ring so I recommanded to adding this Ring middleware: https://github.com/ring-clojure/ring-defaults > This library attempts to automate the process, by providing sensible and secure default configurations of Ring middleware for both websites and HTTP APIs.
hey when you are reducing something with update-in conj.
like (reduce #(update-in %1 [:a] conj %2) {} ["a", "b", "c"])
how can I have control over final output type, conj by default doesnt put into vector
common to see (fnil conj [])
as the updating function. you could also use {:a []}
as your initial value
thanks for fnil, seems bit awkward, i provided static key, but its actually dynamically mapped based on initial-acc