Skip to content

Instantly share code, notes, and snippets.

@mikedouglas
Created April 18, 2010 00:52
Show Gist options
  • Save mikedouglas/369928 to your computer and use it in GitHub Desktop.
Save mikedouglas/369928 to your computer and use it in GitHub Desktop.
(defn- index
[coll]
(map vector (iterate inc 0) coll))
(defn- pos
[elm coll]
(for [[i e] (index coll) :when (e elm)] i))
(defn convert
"Convert the results of `live` into intervals."
[in]
(let [temps (union-all in)]
(for [t temps]
(let [found (pos t in)
reg (if (keyword? (:id t)) (:id t))]
{:id t, :start (first found), :end (last found), :reg reg}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment