                  ; make a q1 -> q1 transtion poping the same symbol from stack
                  ; and input for every terminal symbol.
                  :q1 (concat q1
-                             (map (fn [x] [:q1 x x :ε]) 
+                             (map (fn [x] [:q1 x x :ε])
                                   (mset/difference (set (coll-flatten Σ))
                                                    (set (keys (:prod-rules cfg)))
                                                    #{:ε})))

(defn coll-flatten
  "Flatten any nested coll structure"
  [coll]
  (apply concat 
         (map (fn [x] (if (coll? x) (coll-flatten x) [x]))
              coll)))

(defn cfg-to-ndpda
  "Takes the description of a context free grammar and returns a 
  non-deterministic push down automaton that recognizes the language generated
  by the context free grammar"
  [cfg]

    (list pda i-string next-state stack captures cap-hist)))

(defn first-accepted
  "Calls pred on each member of coll. Expects pred to return a sequential
  datum. Returns the first value of pred that where (first (pred x)) is
  logically true. If none are, returns nil."
  [pred [f & remaining]]
  (if-not f
