More options: I was browsing through the docs and I couldn't find a function
that is the "opposite" of filter, which would allow something like:

(remove nil? coll)

Or alternatively if we had not-nil?

(filter not-nil? coll)

Are either of those more palatable?

In regards to compact removing false, I would be against that, since Clojure
makes a distinction between false and nil. You could, for example, want to
have a collection of boolean values, but want to remove the nils (perhaps
they're a sentinel for some other meaning).

user> (compact [true false nil true true])
(true false true true)

I think it makes sense to have the number functions like max and min throw a
NPE, and since false and nil are distinct, I think it makes sense to have a
compact that removes nil, but leaves false.


Paul

On Thu, Oct 16, 2008 at 4:45 PM, Stuart Halloway
<[EMAIL PROTECTED]>wrote:

>
> Just to add to the confusion: I want compact to remove nil and
> false. :-)
>
> > Perhaps another nudge for compact is that it's not as simple as
> > (filter identity coll), to wit:
> >
> > user> (filter identity [1 2 nil false 4])
> > (1 2 4)
> >
> > user> (filter #(not (nil? %)) [1 2 nil false 4])
> > (1 2 false 4)
> >
> > So unless you want to catch false in your net you really need to be
> > doing the latter, which again is not unreasonable, but just a little
> > messy to be using frequently.
> >
> >
> > Paul
> >
> >
>
> >
>

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

Reply via email to