Re: fastest way to remove nils

2012-10-26 Thread Softaddicts
; > user=> (time (filter identity [ nil 1 2 nil 4])) > > > > "Elapsed time: 0.053219 msecs" > > > > (1 2 4) > > > > > > > > user=> (time (remove nil? [ nil 1 2 nil 4])) > > > > "Elapsed time: 0.065092 msecs&quo

Re: fastest way to remove nils

2012-10-26 Thread kevin roth
cs" > > > (1 2 4) > > > > > > user=> (time (remove nil? [ nil 1 2 nil 4])) > > > "Elapsed time: 0.065092 msecs" > > > (1 2 4) > > > > > > Choose the flavor your prefer... > > >

Re: fastest way to remove nils

2012-10-26 Thread Softaddicts
ote: > > > user=> (time (filter identity [ nil 1 2 nil 4])) > > "Elapsed time: 0.053219 msecs" > > (1 2 4) > > > > user=> (time (remove nil? [ nil 1 2 nil 4])) > > "Elapsed time: 0.065092 msecs" > > (1 2 4) > > > >

Re: fastest way to remove nils

2012-10-26 Thread Moritz Ulrich
2:37:16 AM UTC+1, Luc wrote: >> >> user=> (time (filter identity [ nil 1 2 nil 4])) >> "Elapsed time: 0.053219 msecs" >> (1 2 4) >> >> user=> (time (remove nil? [ nil 1 2 nil 4])) >> "Elapsed time: 0.065092 msecs" >> (1 2 4)

Re: fastest way to remove nils

2012-10-26 Thread kevin roth
il 1 2 nil 4])) > "Elapsed time: 0.065092 msecs" > (1 2 4) > > Choose the flavor your prefer... > > Luc P. > > Glen Rubin > wrote .. > > What is the fastest way to remove nils from a sequence? > > > > I usually use the filter function, but I see

Re: fastest way to remove nils

2010-11-18 Thread Ken Wesson
On Thu, Nov 18, 2010 at 10:47 AM, Glen Rubin wrote: > So, it seems the way I was removing nils using filter was already the > best way.  still nice to learn about the keep fn.  thx! I don't know if we can conclude that yet. It seems to be fastest on one system with one combination of Java version

Re: fastest way to remove nils

2010-11-18 Thread Glen Rubin
So, it seems the way I was removing nils using filter was already the best way. still nice to learn about the keep fn. thx! On Nov 17, 8:38 pm, Ken Wesson wrote: > On Wed, Nov 17, 2010 at 7:55 PM, Robert McIntyre wrote: > > So, just to be clear, > > > user> (def nil-seq (doall (interleave (rep

Re: fastest way to remove nils

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 7:55 PM, Robert McIntyre wrote: > So, just to be clear, > > user> (def nil-seq (doall (interleave (repeat 1e5 nil) (repeat 1e5 > "whatever"))) ) > #'user/nil-seq > > user> (time (doall (keep identity nil-seq))) > "Elapsed time: 122.485848 msecs" > > user> (time (doall (remo

Re: fastest way to remove nils

2010-11-17 Thread Robert McIntyre
))) > "Elapsed time: 0.044 msecs" > () > user> (time (doall (remove nil? (repeat 100 nil > "Elapsed time: 772.469 msecs" > () > > -Steve > > > > > >> >> On Nov 16, 4:48 pm, Glen Rubin wrote: >>> What is the fastest way to

Re: fastest way to remove nils

2010-11-17 Thread Steve Purcell
r YMMV You're not timing the execution, just the construction of a lazy seq: user> (time (remove nil? (repeat 100 nil))) "Elapsed time: 0.044 msecs" () user> (time (doall (remove nil? (repeat 100 nil "Elapsed time: 772.469 msecs" () -Steve > >

Re: fastest way to remove nils

2010-11-16 Thread lprefontaine
Re-oups, Clojure 1.0 to 1.2 upgrade glitch :) Mark Engelberg wrote .. > (keep identity l) is preferable to (filter identity l) > > -- > 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 >

Re: fastest way to remove nils

2010-11-16 Thread lprefontaine
Oups.. :) Stuart Campbell wrote .. > On 17 November 2010 12:37, wrote: > > > user=> (time (filter identity [ nil 1 2 nil 4])) > > "Elapsed time: 0.053219 msecs" > > (1 2 4) > > > > user=> (time (remove nil? [ nil 1 2 nil 4])) > > "Elapsed time: 0.065092 msecs" > > (1 2 4) > > > > Choose the fla

Re: fastest way to remove nils

2010-11-16 Thread Mark Engelberg
(keep identity l) is preferable to (filter identity l) -- 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 po

Re: fastest way to remove nils

2010-11-16 Thread Stuart Campbell
On 17 November 2010 12:37, wrote: > user=> (time (filter identity [ nil 1 2 nil 4])) > "Elapsed time: 0.053219 msecs" > (1 2 4) > > user=> (time (remove nil? [ nil 1 2 nil 4])) > "Elapsed time: 0.065092 msecs" > (1 2 4) > > Choose the flavor your prefer... > > Luc P. > Those aren't exactly equiv

Re: fastest way to remove nils

2010-11-16 Thread Miki
user=> (time (remove nil? (repeat 100 nil))) "Elapsed time: 0.079312 msecs" () user=> (time (filter identity (repeat 100 nil))) "Elapsed time: 0.070249 msecs" () Seems like filter is a bit faster, however YMMV On Nov 16, 4:48 pm, Glen Rubin wrote: > What

Re: fastest way to remove nils

2010-11-16 Thread lprefontaine
user=> (time (filter identity [ nil 1 2 nil 4])) "Elapsed time: 0.053219 msecs" (1 2 4) user=> (time (remove nil? [ nil 1 2 nil 4])) "Elapsed time: 0.065092 msecs" (1 2 4) Choose the flavor your prefer... Luc P. Glen Rubin wrote .. > What is the fastest way t

fastest way to remove nils

2010-11-16 Thread Glen Rubin
What is the fastest way to remove nils from a sequence? I usually use the filter function, but I see there are other functions like remove that should also do the trick. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g