aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/core.clj
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2009-06-03 19:26:48 +0000
committerscgilardi <scgilardi@gmail.com>2009-06-03 19:26:48 +0000
commitbc07de7c3b1058f4263bd7b1c424f771fb010005 (patch)
tree3ec455e14a4333da9cc434e2f8b380af9b19623e /src/clojure/contrib/core.clj
parentabf462cb24fddb21834b523e3c56f568443714f8 (diff)
clojure.contrib.core: add seqable?
Diffstat (limited to 'src/clojure/contrib/core.clj')
-rw-r--r--src/clojure/contrib/core.clj11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/clojure/contrib/core.clj b/src/clojure/contrib/core.clj
index 0397918b..fe6f50e9 100644
--- a/src/clojure/contrib/core.clj
+++ b/src/clojure/contrib/core.clj
@@ -67,4 +67,15 @@
(clojure.lang.RT/classForName class-name)
(into-array Object args)))
+(defn seqable?
+ "Returns true if (seq x) will succeed, false otherwise."
+ [x]
+ (or (seq? x)
+ (instance? clojure.lang.Seqable x)
+ (nil? x)
+ (instance? Iterable x)
+ (-> x .getClass .isArray)
+ (string? x)
+ (instance? java.util.Map x)))
+
;; ----------------------------------------------------------------------