On Jun 3, 8:34 pm, "Stephen C. Gilardi" <[email protected]> wrote:
> On Jun 3, 2009, at 12:53 PM, CuppoJava wrote:
> From that we could derive isSeqable in Java as
>
> static public bool isSeqable(Object coll){
> return
> (coll instanceof ISeq) ||
> (coll instanceof Seqable) ||
> (coll == null) ||
> (coll instanceof Iterable) ||
> (coll.getClass().isArray()) ||
> (coll instanceof String) ||
> (coll instanceof Map);
> }
>
> (ASeq and LazySeq both implement ISeq so their two tests can be
> collapsed into one.)
wouldn't it be best to define seqable? in terms of seq ?
something like
(defn seqable? [x]
(try
(let [s (seq x)]
(when (or s (= s nil))
true))
(catch IllegalArgumentException _ false)))
perhaps not quite as performant but will definitely solve the OP's
problem.
- sean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---