Re: Set some, every, reduce, filter, map methods
Definitely, +1. Also, add reduceRight as well, even if it would only do the same as reduce. Peter Michaux wrote: In another thread, I'm told there is currently no plans to add the following to Set.prototype. some every reduce filter map These seem like very natural additions and the type of operations that one would want to do on sets. Peter ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Set some, every, reduce, filter, map methods
I said this in the other thread but I don't mind repeating myself. A better way forward is to provide these for iterators. mySet.values().some(func) mySet.values().every(func) mySet.values().reduce(func) new Set(mySet.values().filter(func)) new Set(mySet.values().map(func)) I'm not opposed to adding these to Set and Map but I think it is more important to define these using iterators first since it scales better to new collection types. On Mar 30, 2013 8:06 AM, Herby Vojčík he...@mailbox.sk wrote: Definitely, +1. Also, add reduceRight as well, even if it would only do the same as reduce. Peter Michaux wrote: In another thread, I'm told there is currently no plans to add the following to Set.prototype. some every reduce filter map These seem like very natural additions and the type of operations that one would want to do on sets. Peter ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Set some, every, reduce, filter, map methods
Well, why not, but forEach, some, every, reduce[Right] and filter are very natural operations useful for _any_ collection (map is harder). If Set has forEach, it should have these as well. Of course, iterators could have them as well. It is strange if Array and iterators would have it, but other collections would not. The code that takes a collection as a parameter and calls some, every, filter etc. on it would break, instead of doing the job on Set (at least some, every and reduce family can be transparently used; and I would argue for filter as well - it returns subcollection that understands the collection protocol (@@iterator, values, forEach, some, every, filter, reduce, reduceRight)). Herby P.S.: What should generic collection contract consist of in ES6? I would say the except those named above only needed addition is isEmpty, length/size, and possibly clear as well as copy/clone (slice is not right for Set/Map). Erik Arvidsson wrote: I said this in the other thre ad but I don't mind repeating myself. A better way forward is to provide these for iterators. mySet.values().some(func) mySet.values().every(func) mySet.values().reduce(func) new Set(mySet.values().filter(func)) new Set(mySet.values().map(func)) I'm not opposed to adding these to Set and Map but I think it is more important to define these using iterators first since it scales better to new collection types. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Set some, every, reduce, filter, map methods
The order of iteration of a set is the order of insertion of elements into the set. So reduce and reduceRight would actually be different. I should have included reduceRight in my list. Peter On Sat, Mar 30, 2013 at 5:06 AM, Herby Vojčík he...@mailbox.sk wrote: Definitely, +1. Also, add reduceRight as well, even if it would only do the same as reduce. Peter Michaux wrote: In another thread, I'm told there is currently no plans to add the following to Set.prototype. some every reduce filter map These seem like very natural additions and the type of operations that one would want to do on sets. Peter ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Set some, every, reduce, filter, map methods
In another thread, I'm told there is currently no plans to add the following to Set.prototype. some every reduce filter map These seem like very natural additions and the type of operations that one would want to do on sets. Peter ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss