Fork me on GitHub

Is the library unmaintained and deprecated? I need an library like this. What suggestion about trace library? Thanks .

Alex Miller (Clojure team)03:08:23

it’s unmaintained but still works just fine afaik

Alex Miller (Clojure team)03:08:37

I just tried the examples from the README and they worked:

Alex Miller (Clojure team)03:08:41

$ clj -Sdeps '{:deps {org.clojure/tools.trace {:mvn/version "0.7.9"}}}'
Clojure 1.9.0
user=> (use '
user=> (trace (* 2 3))
user=> (trace "tag" (* 2 3))
TRACE tag: 6
user=> (deftrace fubar [x v] (+ x v))
user=> (fubar 2 3)
TRACE t415: (fubar 2 3)
TRACE t415: => 5
user=> (do (+ 1 3) (* 5 6) (/ 1 0))
ArithmeticException Divide by zero  clojure.lang.Numbers.divide (
user=> (trace-forms (+ 1 3) (* 5 6) (/ 1 0))
ArithmeticException Divide by zero
  Form failed: (/ 1 0)
  clojure.lang.Numbers.divide (


Do you know any other similar libraries can trace too?

Alex Miller (Clojure team)05:08:50

I googled “clojure trace” and the first stackoverflow hit seems to have a pretty good range of options on it

Michael Stokley05:08:58

I have a string I would like to evaluate. should i prefer (load-string my-string) or (resolve (symbol my-string))?

Alex Miller (Clojure team)11:08:20

read-string and eval? Depends what constraints you have on the string

Michael Stokley04:08:35

thanks for the reply. some of the strings will resolve to functions i've defined, some to data. the top level goal is to take json, massage it so it looks more like lists and function calls, then evaluate the resulting expressions

Michael Stokley05:08:32

my sense is that load-string is too powerful


@alexmiller Hmm, my bad, I should Google this too. I though experienced Clojurians might know this.

Alex Miller (Clojure team)11:08:52

I tend to mostly work in small pieces evaling into a repl, or if really needed, with a debugger


Hi everyone, I’m trying to make a recursive function to find all possible routes through a graph (encoded as a coll of ‘edges’). So far I’ve got :

(defn extend-path
  [path-so-far graph]
  (let [leading-edge   (last path-so-far)
        candidates     (next-edges leading-edge graph)
        extended-paths (map #(conj path-so-far %) candidates)]
    (if (empty? candidates)
      (vector path-so-far)
      (mapcat #(extend-path % graph) extended-paths))))
Or in pseudocode:
1. Find the possible next edges from path
2. For each edge:
    i.  Append edge to path
    ii. goto 1
which works for small graphs but will explode for bigger ones (no recur). All my efforts to make it work so far have come unstuck due to the fact that each loop requires another iteration over candidates, therefore putting recur out of the tail position. Does anyone have any pointers on where I should look to get around this? Is such a thing possible with nexted loops like this? Thanks


One such failed attempt:

(defn- extend-path
  [init-path graph]
  (loop [path init-path]
    (let [next (next-edges (last path) graph)]
      (if (empty? next)
        (vector path)
        (for [edge next]
          (recur (conj path edge)))))))


@torvaney lots of specifics missing (directed? contains cycles?), but here's a rough idea:

(defn extend-paths [initial-edge graph]
  (loop [paths [initial-edge]]
    (let [paths' (mapcat #(next-paths % graph) paths)]
      (if (= paths paths')
        (recur paths')))))


next-paths would return either a list of continuations, or if there aren't any, a single element list containing the input


you need a much different approach if it's cyclic or undirected


Thanks @moxaj, apologies for the lack of information. The graph is directed, and each edge is forwards-only, so I think you’re solution will get me on the right track.


Thank you very much


hello ppl, I am trying to run the clojurescript quickstart tutorial


but when I run the `clj --main cljs.main --compile hello-world.core --repl’


it hangs and nothing happens

Mario C.16:08:51

When I try to get from postgres db I get an error thrown by which states db-spec ... is missing a required parameter

Mario C.16:08:13

I am using (sql/get-by-id @url <table-name> <the rest of the stuff>)

Mario C.16:08:38

my url is a string containing the database name, user and password.

Mario C.16:08:16

It worked fine when my url was


Is url an atom/etc? Why the @?

Mario C.16:08:07

It is an atom


Can you capture/print the value of @url and make sure the string matches what you expect?

Mario C.16:08:25

Yup its what I expect

Mario C.16:08:43

It prints out the db-spec with {:subname <the url> :subprotocol nil :user "myuser" :password "hunter2"}

Mario C.16:08:33

Looking at the get-connection code it needs some :dbname :dbtype

Mario C.16:08:54

But I thought I am using this

    :connection-uri (required) a String
                 Passed directly to DriverManager/getConnection
                 (both :user and :password may be specified as well, rather
                  than passing them as part of the connection string)


Sorry, you said url was a string; is it a map then?

Mario C.16:08:15

No the error prints out the map, sorry for the confusion

Mario C.16:08:27

url is indeed a string


can you show what the actual value of url is?


subprotocol should be postgresql in that map I think

Mario C.16:08:14

db-spec {:subname <the url> :subprotocol nil :user "myuser" :password "hunter2"} is missing a required parameter


if it’s nil then your url may not have that prefix

Mario C.16:08:32

I think thats what it is


(since it’s failing to parse it)

Mario C.16:08:52

weird because coworker doesn't have that prefix and it works for him


raw string should match the following format, according to the docs:

               An optional prefix of jdbc: is allowed.


hey I am confused on results here is what I do (defn p1 [] (for [x ["1" "2" "3"]] (println x))) (defn p2 [] (for [x ["a" "b" "c"]] (println x))) (do (println "l1") (p1) (println "l2") (p2)) Result is l1 l2 a b c => (nil nil nil) So p1 prints are lost.. why?

Mario C.16:08:05

@dadair Thanks! :thumbsup:


@olekss.janis you can format the code by placing it between lines with “```”


The problem may be lazyness; you probably want to wrap each (for ..) sexp with (doall (for ..))


Hmmm can you explain this lazines, why the first one is not evaluated? Or... what am I missing?


And is there might be better cycle construct which lets me print vector of stuff to the screen?


and yes, that was the problem


Each item individually, on their own line, I assume?


maybe (run! println coll)?


you can replace for with doseq - it uses the same syntax, isn't lazy


run! also works if your case is really that simple though


writing simple console based game as my first meaningful Clojure program, haven't got much far and learned a ton already


#(run! print-factory %) does the same thing


usually in clojure using recur on the rest of a collection means your code could be much simpler


(because something else already does that)

Mario C.18:08:41

Is anyone familiar with VisualVM?

samuel lough19:08:46

Beginner questions on strings vs strings stuck in PersistentLists: I am trying to reverse a list which is easily accomplished by (reverse "hello") however, this returns a type PersistentList (\o \l \l \e \h) The problem is i want to be able to do this: (= "olleh" (reverse "hello")) What is going on here?


If you want it as a string again, you can do (apply str (reverse "hello"))


reverse takes a seqable (which a string is) and returns a seq (which a string is not)

=> (seqable? "hello")
=> (seq? "hello")
=> (seq? (reverse "hello"))
=> (= (seq "olleh") (reverse "hello"))

😀 4

seq is used to turn a seqable into a seq (which is like a list)


no problem!

Mario C.23:08:44

Is there a way I can have Cheshire decode values with certain symbols in them differently?

Mario C.23:08:54



there's a global config iirc

Mario C.23:08:42

Have it look at that ^ and say "okay we have a colon prefixed. Lets make that into a keyword and not a string on decode"


it's easier to use clojure.walk to update your values, but there is a config in jackson to add custom decoders - I know that it exists but not how to use it


user=> (require '[clojure.walk :as walk])
user=> (walk/postwalk #(if (and (string? %) (= (first %) \:)) (read-string %) %) {:a 0 :b "e" :c {:f ":d"}})
{:a 0, :b "e", :c {:f :d}}

Mario C.23:08:58

That would work but I am trying to see if i can do it on a decode


that's going to involve interop with the jackson java library, and a global config

Mario C.23:08:31

If I am already traversing the string why go over it again

Mario C.23:08:56

cheshire doesn't provide anything with values only with keys


cheshire uses jackson, you'd use interop to replicate something like this

Mario C.23:08:41

Thanks :thumbsup:


also depending on your needs, transit can embed in json, and can use first class local decoders (and of course supports basic clojure stuff like symbols, keywords, sets, etc. out of the box)


I've even used transit to encode edn to json, then put that json body directly into mongo