This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-31
Channels
- # aleph (9)
- # bangalore-clj (1)
- # beginners (115)
- # cider (16)
- # clara (20)
- # cljs-dev (47)
- # cljsrn (50)
- # clojure (70)
- # clojure-dusseldorf (2)
- # clojure-italy (16)
- # clojure-sanfrancisco (1)
- # clojure-spec (9)
- # clojure-uk (37)
- # clojurescript (132)
- # cursive (21)
- # datomic (36)
- # dirac (53)
- # fulcro (34)
- # graphql (6)
- # hoplon (96)
- # jobs (2)
- # juxt (2)
- # keechma (2)
- # leiningen (5)
- # off-topic (3)
- # om (2)
- # om-next (3)
- # parinfer (3)
- # re-frame (17)
- # remote-jobs (1)
- # shadow-cljs (57)
- # specter (12)
- # sql (43)
- # unrepl (11)
- # yada (5)
oh wait I think I misunderstood your specification
you would need to write different code, or refactor each prob given the probabilities already seen
Yeah, I’m just looking to return one element from the collection, but that’s still most of the way there for me I think.
(and then call first on the result)
right
you might need to carry a "percentage cumulative" term, which gets us into reduce with a reduced value territory
is there a better way to figure out the namespaces use
d by default in my repl than this?
lagomorph:excl ellisbben$ clj
Clojure 1.9.0
user=> (distinct (map #(get (clojure.string/split (str %) #"['/']") 1) (vals (.getMappings *ns*))))
("clojure.core" nil "clojure.repl" "clojure.pprint" "clojure.java.javadoc")
user=>
It’s configured here btw https://github.com/clojure/clojure/blob/1215ba346ffea3fe48def6ec70542e3300b6f9ed/src/clj/clojure/main.clj#L164
ns-map might do some of that work for you too?
a potentially noob question, is there a one-liner to get rid of the double map access in expressions on the form:
(let [x (when (not (blank? (:key m))) (:key m))]
...)
ie return value from map only if a predicate returns true for it, otherwise nilnew one for me, the docstring for not-empty
reads If coll is empty, returns nil, else coll
…did not make the connection that that would work for strings, guess they are seen as seqs of characters in this context
(defn not-empty
"If coll is empty, returns nil, else coll"
{:added "1.0"
:static true}
[coll] (when (seq coll) coll))
hi everybody, been struggling with compojure-api
. I want to define two defapi
, because I need to wrap the routes with different middlewares. I have the error reported here (and you can see my comment at the end): https://github.com/metosin/compojure-api/issues/206
Anyone using different defapi
in their projects? Thanks 🙂
@U4TE22XR8 does this help? https://github.com/metosin/compojure-api/wiki/Serving-static-resources#this-works
moreover, how can I wrap different api
under the same app
(I am referring to the app
in the link you posted) with specific middlewares?
I think you can just use [ring.middleware.format/wrap-restful-format]
then (uses the default options).
oh, but wait, I am already wrapping with that wrap-restful-format
both the routes. https://github.com/metosin/compojure-api/issues/206#issuecomment-361885758
since I am not getting anywhere with this, do you suggest I give 2.*
a try? I understand there is no ring-middleware-format
.
https://github.com/cretz/asmble <-- how do I figure out if this library is in maven, and if not, how do I include it as a dependency anyway ?
I most of the time google for it, but if it’s on github you can get the source and install it to a local repo.
do these lines mean anything ? https://github.com/cretz/asmble/blob/master/build.gradle#L1-L13
aparently not, should be something like asmble/asmble:0.1.0 and seems like you need kotlin to build
@qqq there’s a mention of adding http://jitpack.io as a maven repo here: https://jitpack.io/#cretz/asmble/0.1.0. Includes Leiningen coordinates, so likely someone’s been using it
Is there a way to store EDN with comments? Or is the only alternative to store is as a string?
if you want to get technical, edn is a serialization format, it only exists as a string
is metadata part of edn officially? if so :doc
metadata might make sense
oh, metadata no, but comments and form discarding yes
(defn ia-eq [lhs rhs]
(let [sl (count lhs)
sr (count rhs)]
(and (= sl sr)
(every? true? (for [i (range sl)]
(= (aget lhs i) (aget rhs i)))))))
(ia-eq (int-array [1 2]) (int-array [1 2]))
(ia-eq (int-array [1 2]) (int-array [1 3]))
this function seems awfully verbose; the (every? true? ....) part is especially uglyhttps://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#equals(int[],%20int[])
(= (seq lhs) (seq rhs))
(let [co (ic/visit {:name "my.dyn.TestClass"
:fields []
:methods [{:name "go", :desc [:long :long]
:flags #{:public :static}
:emit [[:lload 0]
[:ldc2 10]
[:ladd]
[:lreturn]]}]})
obj (ic/new-instance co)]
(obj/to 20))
note that go
is a static field; how do I call it ?there's also a more decomposed form if you are eg. constructing a call from a macro
:user=> (. java.lang.Character isDigit \a)
false
:user=> (java.lang.Character/isDigit \a)
false
I'm having some trouble with a :dynamic that sometimes doesn't appear to be defined when accessed on threads started with pmap. Is using functions that allow for dynamic binding not a good idea in this case?
the binding is only defined in the lexical scope, but due to laziness the actual realization of values can be after you leave the scope
there is (among lots of other great things) a really good explanation of it in The Joy of Clojure
the peril of the perils of dynamic scope : dynamic extent is and stay usefull in some cases. The post is good at pointing out some of the perils, but as is often the case that's not an all black or white thing
@carkh it's the best response to someone asking why dynamic bindings break in pmap though - that's exactly why
also note the article ends with "dynamic is not always bad here's why it's useful and here's how to use it safely"
? it's the last section of the article I'm talking about > Safe Dynamic Scope > So dynamic scope is totally evil, right? Not totally. There are situations where dynamic scope can be helpful without causing the cascade of problems I described above.