On Thu, Mar 26, 2015 at 8:22 PM, Kyle Simpson get...@gmail.com wrote:
outer = outer.filter(function filterer(inner){
return inner.reduce(function reducer(prev,current){
if (prev === false || prev === current) return false;
return current;
});
});
I think you could write that
I think you could write that like this:
outer = outer.filter(arr =
!arr.some((e, i) =
i 0 arr[i-1] === e));
Yes, you are of course correct. What I was doing in the originally cited code
was illustrating using how `reduce(..)` by its nature supports the adjacency
check,
Um, that's not exactly what reduction is meant for.
There's lots of different ways `reduce(..)` gets used in the wild; I can list
several entirely distinct but common idioms right off the top of my head. Just
because it's not the original intent doesn't mean it's invalid to do so.
To the
Kyle Simpson schrieb:
Since `reduce(..)` conveniently can compare two adjacent elements if you always
return the current value, I decided to model the inner check as a `reduce(..)`
that reduces from the original array value to either a `false` or a truthy
value (the last element of the inner
The example code isn't very compelling either; something more real-world
would be good
I recently ran across a usage of `reduce(..)` that could have benefitted from
an early return. Figured I'd just drop it here for posterity sake, in case
anything ever comes of this idea.
I had an array of
erig...@google.commailto:erig...@google.com
Cc: es-discuss@mozilla.orgmailto:es-discuss@mozilla.org
es-discuss@mozilla.orgmailto:es-discuss@mozilla.org
Subject: Re: short-circuiting Array.prototype.reduce
Mark S. Miller wrote:
My other suspicion: The previous failure of this proposal was before many
compelling either; something more real-world would be good there.
--
From: Lee Byron leeby...@fb.com
Sent: 2015-02-23 00:58
To: es-discuss@mozilla.org
Subject: short-circuiting Array.prototype.reduce
Hey all,
I’d like to propose an addition to ES7 to add @@reduced
On Feb 23, 2015, at 7:22 AM, Mark S. Miller wrote:
We still an an option open to us, that would merely compatibly remove a
restriction from the language rather than add a feature: Allow labels to
remain visible across function boundaries, or at least across arrow function
boundaries. Then
very
compelling either; something more real-world would be good there.
--
From: Lee Byron leeby...@fb.com
Sent: 2015-02-23 00:58
To: es-discuss@mozilla.org
Subject: short-circuiting Array.prototype.reduce
Hey all,
I’d like to propose an addition to ES7
Mark S. Miller wrote:
My other suspicion: The previous failure of this proposal was before
many people had much hands on experience using higher order functions
in JS as a normal alternative to control structures. Now that we all
have, the need for a non-local escape may be more visceral.
code isn't very
compelling either; something more real-world would be good there.
--
From: Lee Byron leeby...@fb.com
Sent: 2015-02-23 00:58
To: es-discuss@mozilla.org
Subject: short-circuiting Array.prototype.reduce
Hey all,
I’d like to propose an addition
there.
From: Lee Byronmailto:leeby...@fb.com
Sent: 2015-02-23 00:58
To: es-discuss@mozilla.orgmailto:es-discuss@mozilla.org
Subject: short-circuiting Array.prototype.reduce
Hey all,
I’d like to propose an addition to ES7 to add @@reduced as a way to
short-circuit from
Hey all,
I’d like to propose an addition to ES7 to add @@reduced as a way to
short-circuit from Array.prototype.reduce.
I’ve written up a polyfill and explanation here:
https://github.com/leebyron/ecma-reduced
I would love your feedback on this.
Lee
, for unknown reasons. The example code isn't very
compelling either; something more real-world would be good there.
--
From: Lee Byron leeby...@fb.com
Sent: 2015-02-23 00:58
To: es-discuss@mozilla.org
Subject: short-circuiting Array.prototype.reduce
Hey all,
I’d like
14 matches
Mail list logo