From: skaller <sk...@us...> - 2005-11-24 18:12:13
|
On Thu, 2005-11-24 at 16:23 +0000, Amit Dubey wrote: > I agree: filter implies you're given a container, then you "filter" > away some elements, still left with the same type of container. Impossible for Array[n]. Ocaml Array is bogus type, not encoding the length (since it is fixed length). See below .. > Find_all suggests you're just looking for all matching elements. It > doesn't suggest any particular data structure. So, a list is as good > as anything. A problem -- finding the length of the list, so as to create an array next, is very wasteful. Better to return a list AND the length of the list, then list + length -> Array is fast, and you can make versions of filter and find_all that create arrays. So 3 primitives and 2 derived functions. > One worry with a two-pass approach, though, is it might be > incompatible with find/inclusion functions that contain state (i.e. > the state might get confused on the 2nd call). The whole library has this problem ;( -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net |