Fork me on GitHub
#beginners
<
2023-11-26
>
Aviv Kotek14:11:53

Is there an equivalent in deps clj ? I would like to exclude from all dependencies, and not specifically per one In lein this would work:

:exclusions
[;; Exclude transitive dependencies on all other logging
 ;; implementations, including other SLF4J bridges.
 commons-logging
 log4j
 org.apache.logging.log4j/log4j
 org.slf4j/simple
 org.slf4j/slf4j-jcl
 org.slf4j/slf4j-nop
 org.slf4j/slf4j-log4j12
 org.slf4j/slf4j-log4j13]

practicalli-johnny14:11:50

The docs only cover the case of multiple exclusions with a specific dependency, so the answer seems to be no (or not at the moment) https://clojure.org/reference/deps_edn#_shared_dep_attributes Is there an underlying issue that requires all of these logging related libraries to be excluded?

Aviv Kotek14:11:37

yep. using logback -- following this https://github.com/stuartsierra/log.dev

1
Aviv Kotek15:11:33

you have asked why they should be excluded. this the example I follow with slf4j & logback. which should exclude it alternatives (log4 etc)

practicalli-johnny11:11:01

Sorry I didn't understand the follow-on post at first. I see in the http://log.dev project.clj file that it excludes the transitive dependencies. If the specific library dependencies are not used for http://log.dev project, does it actually fail? It is possible to override a :deps library dependency using an alias with :override-deps to specify the library names and version. I've never tested that for transitive dependencies, but assume that using :override-deps may achieve the same result that http://log.dev project defines in the project.clj :dependencies section. Seems worth a try if http://log.dev project is otherwise not working correctly. https://clojure.org/guides/deps_and_cli#override_deps

Aviv Kotek11:11:24

I'll try, thanks

Audrius16:11:02

hello! I am struggling to write a function that enumerates all possible flight paths for this flight data:

(def available-flights
  {["Prague" "Vienna"] {:price 100 :connections 1}
   ["Prague" "Madrid"] {:price 100 :connections 1}
   ["Vienna" "Zadar"]  {:price 200 :connections 1}
   ["Zadar" "Kiev"] {:price 200 :connections 2}
   ["Zadar" "Madrid"] {:price 200 :connections 1}})
For example, flying from Prague to Madrid. Help is very welcome 😊

Audrius16:11:35

I guess this must be recursive

pppaul16:11:08

Have you tried a graph library?

👍 1
Audrius16:11:38

@U0LAJQLQ1 which one exactly? I will try

pppaul16:11:14

Ubergraph is what I usually use.

1
tomd22:11:23

If this is a learning exercise, or you only have a small amount of flight data / perf isn't important, a recursive solution using no libs could look like this:

(defn find-flights [graph src dest]
  (letfn [(search [current-path visited?]
            (let [current-city (peek current-path)]
              (if (= current-city dest)
                (list current-path)
                (mapcat (fn [[[from to] _]]
                          (when (and (= current-city from)
                                     (not (visited? to)))
                            (search (conj current-path to) (conj visited? to))))
                        graph))))]
    (search [src] #{src})))

tomd22:11:16

And tbh, even using a graph library doesn't stop this being a potentially expensive task. I guess the price and connections data hints that you could path prune, with the trade off of missing some possible (but non-optimal) paths in return for a faster result.

Audrius14:11:05

thank you @UE1N3HAJH 😊 This is extremely helpful 🙂

👍 1