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 On Thu, Oct 16, 2008 at 4:23 PM, Stuart Halloway <[EMAIL PROTECTED]>wrote: > > I am going to vote twice on this one. +2 for adding compact to > Clojure. :-) > > (1) This idiom will occur everywhere. It certainly does in the other > languages I use. > > (2) Clojure needs compact *more* than these other languages, if > functions like max are going to fall out with NPE. I like the idea of > functions not being generally nil-safe where there is no obvious > interpretation for nil. But that raises the need for compact. > > Stuart > > > On Thu, Oct 16, 2008 at 3:26 PM, Paul Stadig <[EMAIL PROTECTED]> wrote: > >> > >> Something like (filter #(identity %) coll) works, but would it be > >> possible > >> to add a 'squeeze or 'compact function so we could do something > >> like (apply > >> max (compact coll))? > > > > I like how few functions clojure has built in (compared to say common > > lisp). It think this is partly achieved through arity overloading, > > but also careful choices about what to include based on how easy it is > > to get what you need through composition. > > > > Is it really worth documenting and making everyone learn what > > "compact" means, so that you can say: > > > > (compact coll) instead of: > > (filter identity coll) ? > > > > --Chouser > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---