 
 ; Searches through particular types of actual results
 
-
-;; (defn- actual-sequential-has-prefix? [expected actual kind]
-;;   (cond (some #{:in-any-order} kind)
-;;         (let [possible-prefix (take (count expected) actual)]
-;;           (empty? (:expected-missed (seq-comparison possible-prefix expected kind))))
-          
-;;         (empty? expected)
-;;         true
-
-;;         (< (count actual) (count expected))
-;;         false
-
-;;         (extended-= (first actual) (first expected))
-;;         (recur (rest expected) (rest actual) kind)
-
-;;         :else
-;;         false))
-
-
-;; (defn- actual-sequential-contains? [actual expected kind]
-;;   (cond (set? expected)
-;; 	(recur actual (vec expected) (conj kind :in-any-order))
-
-;; 	:else
-;; 	(full-sequence-match? actual expected kind)))
-
-;; (defn- actual-map-contains? [actual expected]
-;;   (cond (map? expected)
-;;         (every? (fn [key]
-;;                   (and (find actual key)
-;;                        (extended-= (get actual key) (get expected key))))
-;;                 (keys expected))
-
-;;         (and (sequential? expected)
-;;              (every? like-a-map-entry? expected))
-;;         (actual-map-contains? actual (apply hash-map (apply concat expected)))
-
-;;         :else
-;;         (throw (Error. (str "If " (pr-str actual) " is a map, " (pr-str expected) " should look like map entries.")))))
-
-;; (defn- actual-x-contains? [actual expected kind]
-;;   (cond (singleton-to-be-wrapped? actual expected)
-;;         (recur actual [expected] kind)
-
-;;         (sequential? actual)
-;;         (actual-sequential-contains? actual expected kind)
-
-;;         (set? actual)
-;;         (recur (vec actual) expected [:in-any-order])
-
-;;         (map? actual)
-;;         (actual-map-contains? actual expected)
-
-;;         (string? expected)
-;;         (if (empty? kind)
-;;           (.contains actual expected)
-;;           (recur (vec actual) (vec expected) kind))
-
-;;         (regex? expected)
-;;         (if (empty? kind)
-;;           (re-find expected actual)
-;;           (throw (Error. (str "I don't know how to make sense of a "
-;;                               "regular expression applied "
-;; 			      kind "."))))
-
-;;         :else
-;;         false))
-
-;; (defn- actual-x-has-prefix? [actual expected kind]
-;;   (cond (singleton-to-be-wrapped? actual expected)
-;;         (recur actual [expected] kind)
-
-;;         (sequential? actual)
-;;         (actual-sequential-has-prefix? actual expected kind)
-
-;;         (string? expected)
-;;         (if (empty? kind)
-;;           (.startsWith actual expected)
-;;           (recur (vec actual) (vec expected) kind))
-
-;;         (regex? expected)
-;;         (if (empty? kind)
-;;           (re-find (re-pattern (str "^" (.toString expected))) actual)
-;;           (throw (Error. (str "I don't know how to make sense of a regular expression "
-;; 			      "applied " kind "."))))
-;;         :else
-;;         false))
-
-  
-;; (defn- actual-x-has-suffix? [actual expected kind]
-;;   (cond (singleton-to-be-wrapped? actual expected)
-;;         (recur actual [expected] kind)
-
-;;         (sequential? actual)
-;;         (actual-sequential-has-prefix? actual expected kind)
-
-;;         (string? expected)
-;;         (if (empty? kind)
-;;           (.startsWith actual expected)
-;;           (recur (vec actual) (vec expected) kind))
-
-;;         (regex? expected)
-;;         (if (empty? kind)
-;;           (re-find (re-pattern (str "^" (.toString expected))) actual)
-;;           (throw (Error. (str "I don't know how to make sense of a regular expression "
-;; 			      "applied " kind "."))))
-;;         :else
-;;         false))
-
-(defn collection-like? [thing]
-  (or (coll? thing)
-      (string? thing)))
-
-(defn right-hand-singleton? [thing]
-  (or (not (coll? thing)) (map? thing)))
-
 (defn standardized-arguments [actual expected kind]
   ;; The choice to make these (throw Error) rather than be falsey is purely
   ;; one of implementation convenience.

	:else
	(rotations expected)))

(defn closer-match? [candidate best-so-far]
  (> (count (:actual-found candidate))
     (count (:actual-found best-so-far))))

(defn better-of [candidate best-so-far]
  (if (closer-match? candidate best-so-far) candidate best-so-far))


(defn tack-on-to [hashmap & kvs]
  (merge-with conj hashmap (apply (partial assoc {}) kvs)))


(defmulti seq-comparison (fn [actual expected kind]
			   (or (some #{:in-any-order} kind) :strict-order)))


(defn sequence-success? [comparison]
  (= (count (:expected-found comparison))
     (count (:expected comparison))))

(defn full-sequence-match? [actual expected kind]
  (let [comparison (seq-comparison actual expected kind)]
    (sequence-success? comparison)))

(defn in-any-order--one-permutation [actual expected kind]
  (let [starting-candidate  {:actual-found [], :expected-found [],

;;Checkers that work with collections.


(defn- all-expected-permutations [expected]
  (cond (and (not-any? extended-fn? expected)
