From: Brian H. <bri...@ql...> - 2003-06-01 19:49:12
|
On Thu, 29 May 2003, Alan Post wrote: > > let iter f e = > > let c = e.count() in > > for i = 1 to c do > > f (e.next()) > > done > > > This undoes the lazy nature of Enum.filter, Enum.filter_map, and even > more seriously, input_enum and input_char_enum. Basically, anywhere > the code uses Enum.from will be a problem when relying on Enum.count. > This doesn't change the lazy nature of map- map remains the same. Calling count on the result of Enum.from does force the entire enumeration into memory- granted. Which is why I thought of the has_next() idea. Which means we only need to be one element ahead ever. Personally, I'd also like a way for count to be able to say "I don't know how many elements are in the enumeration". But I got shot down on that last time around. Brian |