From 83238f645e04cd3bb9e68ad882f562afcbfcca86 Mon Sep 17 00:00:00 2001 From: Joel Holdbrooks Date: Thu, 15 Aug 2013 14:20:44 -0700 Subject: [PATCH] Drop precondition, automatically convert inputs to string --- src/clj/frak.clj | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/clj/frak.clj b/src/clj/frak.clj index b00e09a..ad895cc 100644 --- a/src/clj/frak.clj +++ b/src/clj/frak.clj @@ -31,13 +31,13 @@ (defn- trie-put ([s] (trie-put {} s)) ([trie s] - {:pre [(map? trie) (string? s)]} - (if-not (seq s) - trie - (loop [t trie, ps (prefixes s)] - (if-let [cs (and (next ps) (first ps))] - (recur (grow t cs false) (next ps)) - (grow t (first ps) true)))))) + (let [s (str s)] + (if-not (seq s) + trie + (loop [t trie, ps (prefixes s)] + (if-let [cs (and (next ps) (first ps))] + (recur (grow t cs false) (next ps)) + (grow t (first ps) true))))))) (defn- build-trie [strs] (reduce trie-put {} strs)) @@ -91,7 +91,6 @@ ([strs] (pattern strs {:capture? false, :exact? false})) ([strs opts] - {:pre [(every? string? strs)]} (let [pattern (binding [*capture* (:capture? opts)] (-> strs build-trie render-trie str))] (re-pattern (if (:exact? opts) -- 2.25.1