On Wed, Feb 2, 2011 at 3:22 AM, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> On 2 Feb., 08:44, Ken Wesson <kwess...@gmail.com> wrote:
>
>> This also means that macros should not use list? to test whether an
>> object is a nonatomic s-expression. Unfortunately core doesn't contain
>> a compact test for atomicity; to get all the list-y things that print
>> as (foo bar baz ...) you can use something like
>>
>> (and
>>   (coll? x)
>>   (not (or (vector? x) (map? x) (set? x)))
>>
>> which should return logical true only when x is list-y. Wrap that in a
>> predicate function and use it in your macros in place of list?.
>
> seq? should just do fine, since lists are their own seq. coll? just
> checks for IPersistentCollection. Why should that hint to list-y
> printing?

Combining coll? with (not (or (vector?) (map?) (set?))) eliminates the
other three types of coll and leaves seqs and lists.

Oddly, I seem to remember having had to work around a lack of seq?
previously, yet it says on the API page that it's been there since
1.0. Or perhaps it was the larger problem of determining if something
will work with (seq x) that was lacking built-in API...

It does indeed seem that seq? on lists returns true, so it looks like
you can just use that instead of list? in macros to check for (foo
...) s-expressions.

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