On Sun, Jun 28, 2009 at 2:26 AM, Meikel Brandmeyer<m...@kotka.de> wrote:
> Hi,
>
> Am 28.06.2009 um 07:45 schrieb Handkea fumosa:
>
>> It's list? that isn't.
>
> No. list? is not broken. Every list is a seq, but not
> every seq is a list.
>
> Consider: (cons 0 (iterate inc 1))
>
> This is no list! It's a sequence. Why should list?
> return true?
>
> In Clojure there is no such thing as a cons cell.
> There is only an abstraction of a cons cell where
> the second part must implement again the
> sequence abstraction.
>
> If you need a cons cell, use a two-element vector
> or a two-element list.
>

This is overstating things. There certainly is a cons cell, it's
called Cons, and cons produces one. It differs from CL cons cell in
not being an arbitrary pair (i.e. the rest must be a sequence or nil).

> Please: If you want to program CL in Clojure...
> Don't do it. Clojure is different. Claiming parts
> of Clojure are broken because they don't behave
> like something is else doesn't make sense and
> hence leads nowhere.
>

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.

Because Clojure supports a seq abstraction, there is heterogeneity in
the implementations. In fact there are two cons-cell-like data
structures:

user=> (class (cons 4 '(1 2 3)))
clojure.lang.Cons
user=> (counted? (cons 4 '(1 2 3)))
false

user=> (class (conj '(1 2 3) 4))
clojure.lang.PersistentList
user=> (counted? (conj '(1 2 3) 4))
true

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

cons onto an IPersistentList could be made to return another
IPersistentList, but currently doesn't.

Rich

--~--~---------~--~----~------------~-------~--~----~
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