This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-11
Channels
- # announcements (1)
- # aws (2)
- # beginners (140)
- # boot (67)
- # cider (50)
- # clojure (64)
- # clojure-berlin (1)
- # clojure-conj (1)
- # clojure-france (2)
- # clojure-italy (2)
- # clojure-nl (8)
- # clojure-norway (6)
- # clojure-seattle (1)
- # clojure-spec (81)
- # clojure-sweden (2)
- # clojure-uk (131)
- # clojurescript (147)
- # clojutre (7)
- # cursive (40)
- # datomic (34)
- # editors (5)
- # emacs (7)
- # events (9)
- # figwheel (18)
- # figwheel-main (1)
- # fulcro (2)
- # instaparse (1)
- # jobs (3)
- # leiningen (1)
- # luminus (10)
- # lumo (1)
- # mount (6)
- # off-topic (12)
- # pedestal (4)
- # portkey (7)
- # re-frame (8)
- # reagent (21)
- # reitit (10)
- # ring-swagger (5)
- # shadow-cljs (140)
- # specter (4)
- # tools-deps (53)
- # uncomplicate (1)
Should this still be throwing an EOF
exception?
(require '[clojure.edn :as edn])
(edn/read-string {:eof nil} "{:a")
;; => RuntimeException EOF while reading
Shouldn't it return nil
instead?:eof is a read option that tells read what to return if the stream it is reading forms from is empty
I have two lists, with items list A ["a" "b" "c"]
list B ["a" "b" "f" "z"]
now I want to remove the items from the beginning of list B that are equal, ending up with ["f" "z"]
. Previously I did something with (->> (map vector A B) (drop-while #(= (first %) (second %)))
but that isn't working when the lists aren't of equal length. I could pad them but that just seems off. What's a nice way of doing this?
(def A ["a" "b" "c"])
(def B ["a" "b" "f" "z"])
A way that produces the result you want:
(->> [B A] (map (partial apply sorted-set)) (apply clojure.set/difference) vec)
note only works if initial sequence of seqs if sorted by longest-length first. not sure it's "nice" really.
The idea in my solution is to essentially filter element by element using items from A, but there is no extra cost because drop-while
will stop once the predicate returns false. Which means that once you've exhausted your "prefix" you will simply walk the rest of your filtering list (A in this case) but never traverse B anymore.
thanks! that reduce thing is neat. the set approach seems a bit more indirect but it also works, so yeah!
https://github.com/cljdoc/cljdoc/commit/125f4f6c6ccd0e93e3c89bd44834e16248f2d55d
Thanks ❤️ (sorry for not crediting, should have done so but only realized after pushing and now I don't want to mess with history)
I tried to make a solution with loop
! It prevents you from having to iterate over all of A.
Compares the first two elements of A and B... if they are equal then recurse with the rest's of the lists, and if they are different then return B.
(loop [a '("a" "b" "c" "d")
b '("a" "b" "f" "g" "h")]
(if (and (= (first b) (first a))
(not-empty b))
(recur (rest a) (rest b))
b))
@U1NDXLDUG ugh, unlikely case but I see your point. Want to make a PR with a fix? 😄
There's an early-termination version of reduce
available as well:
(reduce
#(let [new (drop-while (partial = %2) %1)
same? (= %1 new)]
(if same?
(reduced new)
new))
B A)
Though honestly one should factor in readability, and unless you know your input is going to be huge I'd say early termination is not worth the effort.ended up with this now: https://github.com/cljdoc/cljdoc/blob/d5dad8336efc723200f085cf3e8ffbb47d43b0ed/modules/shared-utils/src/cljdoc/util.clj#L171
hello, lein licenses
- has an authentication problem accessing dependency poms. despite that lein deps
is able to download the deps. Do you have an idea what lein licenses
does wrong or what is needed to apply the :auth specification from profiles.clj in a plugin?
@gv it might be that it's simply not using any Auth stuff from project.clj and assumes all dependencies' POMs can just be retrieved without authentication (but I don't know/haven't checked)
sorry if this is a faq, but has anyway a handy (macro) implementation of the js spread (…) operator.
hello! may you can help me? it is possible to set, through repl, the *command-line-args*
to be abble to try tools.cli options in place?
@U2CVD69EC take a look at binding
👍 tks!
welcome! btw, I'd expect that tools.cli also has some APIs where you can just pass the data. Maybe try looking at it's tests or so...
yeah I think you just want to use apply
, do you really need it to be a macro? spread
is a private implementation function
@martinklepsch yeah, the :auth data seems to get lost in the call chain
@martinklepsch it seems aether expects the auth data in the repository settings map - do you know where leiningen combines that?
like, a million years ago, I wrote a thing that let me embed a clojure repl in a jenkins process
https://github.com/hiredman/jenkins-clojure-injector https://github.com/hiredman/jenkins-nrepl
I also happened to find this one https://github.com/inventiLT/jenkins-rabbitz
do idependent/custom hierarchies get much use? anywhere i could be looking for reference?
@UCDG904RW not really, but if you want an example, this may help https://github.com/dawcs/zakon/blob/master/src/zakon/core.clj#L12
Maybe this should be in #off-topic, but it’s language related, so I’ll speculate out loud here…
I wonder why Clojure doesn’t have clojure.core/ex-message
as a complement to cljs.core/ex-message
? Both Clojure and ClojureScript create an ExceptionInfo
object with ex-info
, and both retrieve the associated data structure with ex-data
. Then in ClojureScript I can get the message with ex-message
, but in Clojure I need to use interop to get the message. There’s no requirement that the core library for both languages be as close as possible to copies of each other, but it does seem inconsistent. It’s also strange to require host interop to get the message out of a native part of the language.
Does anyone know if there is a good reason why this is missing please?
cljs added it and no one ever filed a ticket to do so in CLJ
@quoll I was thinking of the same, but for ex-cause
. Perhaps the answer is that Exception
s have messages and causes
There is a ticket you can vote on: https://dev.clojure.org/jira/browse/CLJ-1120
oh wow, deep ticket :)
I’ll see if I can get that bumped for 1.10
if anyone wants to check and update the patch, that would be helpful
You think it needs test cases? The implementations are fairly straightforward, so maybe no.
I suspect there are some already
but might need something new