On Jun 28, 11:21 am, Rich Hickey <richhic...@gmail.com> wrote:
> This too is a bit much. The OP wasn't trying to use cons as a pair,
> just expecting list? to be more similar to listp. It's a reasonable
> mistake, please be gentle.

If you're referring to me, I don't agree that it is a mistake to
expect that there'd be a correspondence between (1 2 3), [1 2 3], #{1
2 3), {:one 1 :two 2 :three 3} and list?, vector?, set?, and map?

> Because Clojure supports a seq abstraction, there is heterogeneity in
> the implementations.

Heterogeneity that often ought to be hidden from the user.

The major way in which a seq could fail to be list-like is if it were
infinite. Unfortunately there doesn't seem at present to be an
efficient infinite? predicate. (Actually, for custom uses of lazy-seq
that might run afoul of the so-called halting problem. Perhaps a
possibly-infinite? predicate which could return true for the results
of lazy-seq, repeatedly, iterate, and their ilk, false for the results
of take, list, and the like, and the same value as for the input seq
in the case of map, cons, and the like; for for, it would be true if
any of the input colls was possibly-infinite? and for interleave,
false if any were not. Then a test for "listiness" could check for
sequential?, not vector?, and not possibly-infinite?.

Implementing the above would require adding an isPossiblyInfinite
method to some of the clojure.lang interfaces and classes, and in some
cases a field for this to return, with code to compute its value in
the constructor.

> So, list? is more specific because seqs are more general. seq? is
> probably what is desired.

That does seem to be false for vectors and true for the () colls I
threw at it, including a quoted list, a cons, and a map output.

Is it equivalent to "is a () coll"?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to