update 'contains' to allow checking for a substring in a string

This commit is contained in:
Gered 2014-06-14 22:56:54 -04:00
parent 4ca3efc9f7
commit ceed7a25a0

View file

@ -38,10 +38,12 @@
"contains"
{:fn (fn [coll value]
(if (map? coll)
(contains? coll (possible-keyword-string value))
(cond
(map? coll) (contains? coll (possible-keyword-string value))
(string? coll) (.contains coll value)
; explicit use of '=' to allow testing for falsey values
(some #(= value %) coll)))}
(coll? coll) (not (nil? (some #(= value %) coll)))
:else (throw (new Exception (str "'contains' passed invalid collection type: " (type coll))))))}
"dump"
{:fn (fn [x]