Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Commit

Permalink
Rename uber-flatten to symbols-in-body.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Dec 24, 2012
1 parent 7106122 commit f96e740
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/slam/hound/regrow.clj
Expand Up @@ -44,19 +44,15 @@
(finally
(remove-ns (.name *ns*)))))))

(defn- uber-flatten
"Like flatten but will flatten into anything that is a coll?,
which means we can flatten namespace bodies that contain sets and maps."
[x]
(filter (complement coll?)
(rest (tree-seq coll? seq x))))
(defn- symbols-in-body [body]
(filter symbol? (remove coll? (rest (tree-seq coll? seq body)))))

(def ^:private ns-qualifed-syms
(memoize (fn [body]
(apply merge-with set/union {}
(for [value (uber-flatten body)
:when (symbol? value)
:let [[_ alias var-name] (re-matches #"(.+)/(.+)" (str value))]
(for [value (symbols-in-body body)
:let [[_ alias var-name] (re-matches #"(.+)/(.+)"
(str value))]
:when alias]
{alias #{(symbol var-name)}})))))

Expand Down

0 comments on commit f96e740

Please sign in to comment.