KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there an idiomatic way of determining if a LazySeq contains an element? As of Clojure 1.5 calling contains? throws an IllegalArgumentException: IllegalArgumentException contains? not supported on type: clojure.lang.LazySeq clojure.lang.RT.contains (RT.java:724) Before 1.5, as far as I know, it always returned false. I know that calling contains? on a LazySeq may never return as it can be infinite. But what if I know it isn't and don't care if it is evaluated eagerly? What I came up with is: (defn lazy-contains? [col key] (not (empty? (filter #(= key %) col)))) But it doesn't feel quite right. Is there a better way?
Tags (comma-separated)
Save Edits
Cancel