Fork me on GitHub
Rob Haisfield00:07:31

Awesome, thank you @smith.adriane for the helpful explanations. That cleared up a lot for me

👍 3
Rob Haisfield00:07:31

Is there equivalent to contains? for finding if a value is present in a map?

contains? Returns true if key is present in the given collection, otherwise
returns false.


You can also use Java interop for this:

(.containsValue {:a 1} 1)
;> true
But this won't be portable to other Clojure dialects, like it won't work in ClojureScript. If you want something portable, better stick to using some.

Rob Haisfield00:07:16


(value-contains? {:a 1} 1) => true


I'd probably use something like (some (comp #{1} val) the-map)

🚀 3

user=> (def the-map {:a 1 :b 2})
user=> (some (comp #{1} val) the-map)
user=> (some (comp #{2} val) the-map)
user=> (some (comp #{3} val) the-map)


if you need more than true/false, can use medley.core. see filter-vals,


why is this test failing :

(def __ '(5 2 4))

   [2 5 4 1 3 6]
   (drop 2)
   (take 3)
   (map inc))

 (__ (map inc (take 3 (drop 2 [2 5 4 1 3 6])))) := (->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (__)))

Geoffrey Gaillard08:07:10

It seems you are calling as a function with ()


you mean the answer is only 5 2 4 without the parentheses ?

Geoffrey Gaillard08:07:35

is a value. You could try (map inc (take 3 (drop 2 [2 5 4 1 3 6])))) :=

Geoffrey Gaillard08:07:36

'(5 2 4) is a list. So calling it like () is equivalent to ('(5 2 4)), meaning "call this list as a function", which fails.


so the answer needs to be onky 5 2 4


({:xAxisValue "MAR 2017", :yAxisValue "NA", :clientYAxisValue 2, :client10p 0, :client90p 0 :shareYAxisValue 6, :share10p 1, :share90p 1}
           {:xAxisValue "APR 2017", :yAxisValue 1, :clientYAxisValue 4, :client10p 0, :client90p 0 :shareYAxisValue 7, :share10p 1, :share90p 1}
           {:xAxisValue "MAY 2017", :yAxisValue 2, :clientYAxisValue 5, :client10p 0, :client90p 0 :shareYAxisValue 8, :share10p 1, :share90p 1}
           {:xAxisValue "JUNE 2017", :yAxisValue 5, :clientYAxisValue "NA", :client10p "NA", :client90p "NA" :shareYAxisValue "NA", :share10p "NA", :share90p "NA"})


user=> (def a '({:x 1 :y 1} {:x 2 :y 2}))
user=> (def b '({:x 1 :z 1} {:x 2 :z 2}))
user=> (map #(apply merge %) (vals (group-by :x (concat a b))))
({:x 1, :y 1, :z 1} {:x 2, :y 2, :z 2})


Hey, could someone help me to configure emacs+cider pprint? I'm currently facing the problem that my emacs freezes when I try to pprint a long string. I tried (setq cider-print-options '(("length" 50) ("right-margin" 70))) but this does not resolve the issue (or I'm missing something)


Hello, may I know if a Ring server automatically handles multiple requests? o:


Yup, ring’s default jetty web server and most others will have a thread pool to handle concurrent requests. Ring itself though is more like a pattern for working requests at the application level.


Hello, I've set up an http-kit server on localhost:3000 which I'm trying to call from a cljs app on 9090, but I keep getting a Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at . (Reason: CORS header 'Access-Control-Allow-Origin' missing). I have ring-cors set up, but it doesn't look to me like the "Allow" header is being populated. My app looks like this:

(def app
  (-> #'routes
      (wrap-defaults site-defaults)
      (wrap-cors :access-control-allow-credentials "true"
                 :access-control-allow-origin [#""])))
Full file curl --head localhost:3000 gives the following, also missing the origin allow
HTTP/1.1 200 OK
Content-Type: application/json
Set-Cookie: ring-session=64c4da9f-5dd2-4b62-9ae6-d1eff297d835;Path=/;HttpOnly;SameSite=Strict
X-Xss-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Length: 0
Server: http-kit
Date: Sun, 25 Jul 2021 15:16:18 GMT
am I not using the wrap-cors correctly? Thanks!


Thanks Cora, I made the change (silly typo), but no dice unfortunately. To be clear, the curl works fine, and returns as I expect it to, just missing the allow header. It's only when I hit it from the browser that it doesn't work.


▶ curl -X OPTIONS localhost:3000 -i    
HTTP/1.1 404 Not Found
Content-Length: 0
Server: http-kit
Date: Sun, 25 Jul 2021 15:48:28 GMT
▶ curl  localhost:3000 -i          
HTTP/1.1 200 OK
Content-Type: application/json
Set-Cookie: ring-session=6b7042cf-4a86-484c-bac2-13a0217f349e;Path=/;HttpOnly;SameSite=Strict
X-Xss-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Length: 17
Server: http-kit
Date: Sun, 25 Jul 2021 15:48:58 GMT



I see, thanks - I guess I need to read more about the preflight request and how they work

Karol Wójcik16:07:02

Curl will probably always work for preflight


Maybe a late answer... but I had this problem... and after much searching ... I figured out that in the service settings I needed to have ::http/secure-headers {:content-security-policy-settings {:object-src "none"}} as one of the entries... This is for my pedestal server setup tho... so keep that in mind!! Happy Clojuring!!


Thanks ChillPillzKillzBillz, I'll give that a go.

Samuel Couto19:07:22

Hello, how a LocalDateTime is declared using spec-tools?


@samuel.couto92 that seems to work for me? ^

Samuel Couto20:07:31

It works, thanks 😄


If I have an s-expression with metadata that includes line+col information, is there any built in function that can either print out that s-expression putting in line breaks as appropriate? (Alternatively converting the s-expression to a string works.)


Im not sure if there is something taking into account the metadata but for printing human readable s-expressions there is


@U6JS7B99S Does pprint print things out in a way that can be read back in with, say read-string?


I believe that there are cases where it doesn't - for example printing a java class instance. It also cannot read back in record instances (It would read them as plain maps)


As far as EDN-ready values go it should, I believe, be possible


Which is about what I would expect from pr and prn.


Still sad that it will reflow everything, but I guess it can't be helped. Thanks.


you may be interested in something like which can read edn and preserve whitespace.


Basically, looking for something machine readable, but with human-readable spacing.


How would you summon the find-versions tool talked about I'm trying clj -X:deps find-versions :lib io.github.clojure/tools.deps.graph and all I get is the error message Function not found:


What version of the clojure cli are you using ?


Is that the prerelease version? The new goodies haven’t made it into a stable release yet


ohhhhh probably not.


weird that it would already be in the official docs...


@cdimara I think Alex was hoping to get to a stable release faster -- but there have been a number of bug fixes on the prerelease side and the Windows scripts also needed to be substantially updated.


(I suspect he also hoped folks read the news article about the changes -- -- where it mentions the prerelease... but it certainly has caused some confusion for quite a few folks based on the Qs I've seen posted here in various channels and on ClojureVerse)


The latest prerelease is I believe (we're on at work). You can see all the release numbers here but only stable releases are listed here (and I don't think anyone would expect folks generally to tie Clojure CLI to brew-install when trying to figure that out, which is why I'm linking to it).


Oh man I totally read that article. And I assumed it was about features in a current release. Glazed right over the installation part. sorry.


Easy to miss: it's only mentioned on one line over halfway through the article I think...


I'll make the same offer here that I've made in a few other threads: my DMs are always open for any Qs about the Clojure CLI, tools.deps,, and stuff like clj-new, depstar, etc 🙂 (which will make sure I see the Q, whereas I might miss it here)

thanks3 6
👍 2

A lot of deps.edn tooling out there still assumes -A as the way to invoke things (despite how long there has been a warning to use -M instead) and a lot of people are still using old CLI installs that don't support -X so that also adds to the confusion (in the opposite direction).


(and the behavior of -M changed so old CLI versions don't get the warning for using -A but can't actually use -M because it hadn't used to pick up dependencies!)