Fork me on GitHub

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?


I am not sure :eof nil has any effect for read-string


:eof is a read option that tells read what to return if the stream it is reading forms from is empty


so maybe the thing for read-string would be {:eof nil} with "" as the input


but if eof is encountered in the middle of reading a form that is always an error


The docs could be more clear on that


lesson: be careful when you use multi-arity in combination with varargs?


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"])


is it important to preserve order?


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.


(reduce #(drop-while (partial = %2) %1) B A)


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!


Thanks ❤️ (sorry for not crediting, should have done so but only realized after pushing and now I don't want to mess with history)


"Lift" away! 🙂


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))



user=> (relativize-path "a/b.html" "a/a/b.html")


@U1NDXLDUG ugh, unlikely case but I see your point. Want to make a PR with a fix? 😄


not really


There's an early-termination version of reduce available as well:

  #(let [new (drop-while (partial = %2) %1)
            same? (= %1 new)]
       (if same?
          (reduced 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.


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


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...


I understand that it’s mainly achieved by using apply, but…


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?


it is hidden in classpath/add-rep-auth


Has anyone ever written a plugin for Jenkins in Clojure?


like, a million years ago, I wrote a thing that let me embed a clojure repl in a jenkins process


do idependent/custom hierarchies get much use? anywhere i could be looking for reference?


oh this is very interesting, thanks!


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?

Alex Miller (Clojure team)22:09:49

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 Exceptions have messages and causes

Alex Miller (Clojure team)22:09:18

I’ll see if I can get that bumped for 1.10


Yeah, that one predates reader conditionals 🙂

Alex Miller (Clojure team)22:09:37

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.

Alex Miller (Clojure team)00:09:51

I suspect there are some already

Alex Miller (Clojure team)00:09:58

but might need something new


is there a plugin that will list the failing namespaces here at the bottom? as a summary


else I have to scroll a lot and search them in the middle of huge stacktraces