From: Amit D. <ami...@gm...> - 2005-11-24 15:56:24
|
On 11/24/05, Richard Jones <ri...@an...> wrote: > > Array.find > > > > Will this return the element or an index? > > I'm not sure which is better? I think probably having Array.find be > exactly like List.find, ie. returning an element, and having an > additional Array.find_index to return the index would be the best > idea. What do people think? I agree that returning the element is similar to what List does, but arrays are not lists ;) I would argue that something like find_index is all that'= s necessary, and you can do a lookup if you need the element. > Array.filter > > Array.find_all > > Array.partition > > > > Would these return lists or arrays? > > I think it's better to return arrays, but what do people think about > that? Actually, I agree it makes complete sense for partition. As I think about it, I think filter and find_all should be different. find_all should retur= n a list, and filter should return an array. And possibly, filter should be defined in terms of find_all. -Amit |