1. Re: FindAll
- Posted by "Boehme, Gabriel" <gboehme at MUSICLAND.COM> Apr 19, 1999
- 510 views
Hawke' wrote: >off the top of my head, I keep thinking the following would >be far faster, especially considering EU's new optimizations... > >function find_all(object value, sequence s) >sequence list list = {} > for i = 1 to length(s) do > if equal(s[i],value) then > list = append(list,i) > end if > end for > return list >end function > >dunno if it's actually faster, >(or if it even works :) ) >but IMO it's worth a try, eh? Yes! It works just fine, and I like how concise and clear the code is compared to mine. Unfortunately, it isn't quite as fast -- on my machine, a million iterations of your routine took about 6.3 seconds, while a million iterations of mine took about 5.8 seconds. The reason for this (I believe -- somebody correct me if I'm wrong) is that Euphoria's built-in find() function can run thru the elements of a sequence faster than Euphoria's "for" loops can. Be seeing you, Gabriel Boehme ------ Writing comes easy. All you have to do is stare at a blank piece of paper until your forehead bleeds. Douglas Adams ------