A friend asked how to find strongly connected components in a graph in idiomatic Clojure. This is what I came up with: (defn edge-list [g] (mapcat (fn [[k v]] (map (partial vector k) v)) g)) (defn reverse-graph [g] (reduce…
Category archive for: Lisp
I was trying to write a PDDL parser in Clojure, and realized it could be handy to have something that does the opposite of `(~x ~@y). In other words, it takes a two versions of a syntax-tree, one with variables…
If you’re running experiments in Lisp and want to know the total amount of memory currently in use (i.e., by live objects), it’s much less straightforward than you might think. The following code gets this number in a handful of…