Re: please add orEqual operator

2015-08-09 Thread Michael A. Smith
I was going to suggest a Set, now that ECMA has them… http://www.ecma-international.org/ecma-262/6.0/index.html#sec-set-objects ```js if ((new Set([1,2,3,5]).has(a)) { // stuff } ``` On Sun, Aug 9, 2015 at 4:20 PM wrote: > it could be used like this: > > if ( a == 1 ||= 2 ||=3 ||=5) { //

Re: try without catch or finally

2012-04-18 Thread Michael A. Smith
try foo(); catch bar(); finally cleanUp(); in the same spirit as if (foo) doFoo(); else doBar(); -Michael A. Smith On Wed, Apr 18, 2012 at 5:45 AM, Jussi Kalliokoski wrote: > >> Silent catch-alls like that are almost always bad code. I think the >> language rather shouldn&

Re: set.empty() method

2012-02-15 Thread Michael A. Smith
+1 on clear() as it's pithy, understandable, and behaves the same in Java and Python. What real benefit comes from drawing this connection between delete() and deleteAll()? I suspect the everyday programmer won't care, and the ones who do will look it up. -Michael A. Smith On Wed, Fe

Re: Set iterators

2012-02-13 Thread Michael A. Smith
ng. But hypothetically let's say we do want to go with insertion-order. In that case, what happens to the order when you attempt to insert an element that already exists in the set? OrderedSet('a', 'b', 'c').insert('b') Is that

Re: Set constructor arguments

2012-02-12 Thread Michael A. Smith
#x27;bar', 'baz']), which requires two constructions, one of which is essentially a waste. If allowing both forms of the constructor is distasteful, then why not just go with the multiple parameters, approach, and implement toSet() as a method on appropriate Iterables? -Michael A

Re: Array extras functionality for iterators

2012-02-04 Thread Michael A. Smith
such methods. Something like someVeryLargeArray.iMap(someFunction); // Lazy, guaranteed only to be iterable (No apologies to the email protocol.) What do you think? -Michael A. Smith On Fri, Feb 3, 2012 at 3:54 PM, Domenic Denicola wrote: > > iterator.map(mapper).some(predicate) //

Re: Array extras functionality for iterators

2012-02-04 Thread Michael A. Smith
Sorry for the resend. Meant to include the list. I like this idea a lot! However, what would be the correct behavior of a method like 'every' on an infinite generator? -Michael A. Smith On Fri, Feb 3, 2012 at 3:54 PM, Domenic Denicola wrote: > ES5's existing array extras

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Michael A. Smith
urely be useful.) Michael A. Smith Web Developer True Action Network, an eBay Company On Tue, Jan 3, 2012 at 1:12 PM, Rick Waldron wrote: > > > On Tue, Jan 3, 2012 at 12:50 PM, Sean Eagan wrote: >> >> I think step should be > 0, and step towards end: >> >>

Re: Suggestion: Array.prototype.repeat

2012-01-02 Thread Michael A. Smith
the difference in overhead between instantiating a new array and using Array.prototype.slice.call on arguments really worth sacrificing consistency with the proposed string.prototype.repeat and the very clean syntax of someArray.repeat(n)? Michael A. Smith Web Developer True Action Network (a

Re: String.prototype.until

2012-01-02 Thread Michael A. Smith
allow the developer to decide the starting index? String.prototype.until = function (start, needle) { return "" + (this.substr(start, this.indexOf(needle)) || this); } (The ["" +] part is probably not necessary, but it makes it easier to see the implementation work in