Miki <miki.teb...@gmail.com> writes: > user=> (time (remove nil? (repeat 1000000 nil))) > "Elapsed time: 0.079312 msecs" > () > user=> (time (filter identity (repeat 1000000 nil))) > "Elapsed time: 0.070249 msecs" > () > > Seems like filter is a bit faster, however YMMV
You're not timing the execution, just the construction of a lazy seq: user> (time (remove nil? (repeat 1000000 nil))) "Elapsed time: 0.044 msecs" () user> (time (doall (remove nil? (repeat 1000000 nil)))) "Elapsed time: 772.469 msecs" () -Steve > > On Nov 16, 4:48 pm, Glen Rubin <rubing...@gmail.com> wrote: >> 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 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