diff options
Diffstat (limited to 'src/clojure/contrib/seq_utils.clj')
-rw-r--r-- | src/clojure/contrib/seq_utils.clj | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/clojure/contrib/seq_utils.clj b/src/clojure/contrib/seq_utils.clj index 5f3b7446..ad913f70 100644 --- a/src/clojure/contrib/seq_utils.clj +++ b/src/clojure/contrib/seq_utils.clj @@ -211,20 +211,12 @@ (cons (if (identical? x NIL) nil x) (drain)))))))))) -(defmulti positions - "Returns a lazy sequence containing the positions at which item - is found in coll. Functions (responding true to fn?) are called - against members of the collection, other items are compared for - equality." - { :arglists '([item-or-pred coll]) } - (fn [item-or-pred _] - (if (fn? item-or-pred) :pred :item))) - -(defmethod positions :pred [pred coll] +(defn positions + "Returns a lazy sequence containing the positions at which pred + is true for items in coll." + [pred coll] (for [[idx elt] (indexed coll) :when (pred elt)] idx)) -(defmethod positions :item [item coll] - (for [[idx elt] (indexed coll) :when (= item elt)] idx)) |