Skip to content →

Date archive for: December 2008

Strongly Connected Components in (mostly?) idiomatic Clojure

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…

Matching in Clojure

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…