Re: Array Comprehensions

2017-04-16 Thread Allen Wirfs-Brock
round >> use of comprehension syntax, but I personally (at least) love the >syntax >> in the ES reference >> >(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions). >> >> The best previous discussion on this that I found

Re: Array Comprehensions

2017-04-16 Thread Herby Vojčík
/docs/Web/JavaScript/Reference/Operators/Array_comprehensions). The best previous discussion on this that I found was six years old (https://esdiscuss.org/topic/array-comprehensions-shorter-syntax) and answers some of my questions, raising others. That said, I wanted to ask: * Why

Re: Array Comprehensions

2017-04-16 Thread Cyril Auburtin
I often use ```js Array.from({length: n}, (_, i) => i**2) Array.from({length: n}, (_, i) => Array.from({length: n}, (_, j) => i*j)) [].concat(...Array.from({length: n}, (_, i) => Array.from({length: n}, (_, j) => ({i,j,v:i*j} // flattened ``` 2017-02-07 23:13 GMT+01:00 kdex :

Re: Array Comprehensions

2017-02-07 Thread kdex
AFAIK, only TC39 members can champion a proposal. If you're not a member, you could still write a proposal and hope that some TC39 member is interested in championing it. On Tuesday, February 7, 2017 5:05:49 PM CET Ryan Birmingham wrote: > It wasn't clear from the documentation; who can or

Re: Array Comprehensions

2017-02-07 Thread Ryan Birmingham
It wasn't clear from the documentation; who can or cannot be a champion? -Ryan Birmingham On 7 February 2017 at 10:49, Bob Myers wrote: > On Tue, Feb 7, 2017 at 6:58 PM, David Bruant wrote: > >> At the very least, the proposal will be listed in the stage 0

Re: Array Comprehensions

2017-02-07 Thread Bob Myers
On Tue, Feb 7, 2017 at 6:58 PM, David Bruant wrote: > At the very least, the proposal will be listed in the stage 0 proposals > list [3]. My understanding is that a champion is required even to become stage 0. ___ es-discuss

Re: Array Comprehensions

2017-02-07 Thread David Bruant
://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions). The best previous discussion on this that I found was six years old (https://esdiscuss.org/topic/array-comprehensions-shorter-syntax) and answers some of my questions, raising others. That said, I wanted

Re: Array Comprehensions

2017-02-06 Thread Tab Atkins Jr.
add it.) Aside: double-for in array comprehensions is only Pythonic in very simple cases; it's usually quite hard to read. The functional version is somewhat better imo: numbers.flatMap(i => letters.map(j => i+j)); ~TJ ___ es-discuss mailing list e

Re: Array Comprehensions

2017-02-06 Thread Gil Tayar
he syntax in the ES > reference ( > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions > ). > > The best previous discussion on this that I found was six years old ( > https://esdiscuss.org/topic/array-comprehensions-shorter-syntax) and > answe

Re: Array Comprehensions

2017-02-06 Thread T.J. Crowder
mprehensions). > > The best previous discussion on this that I found was six years old ( > https://esdiscuss.org/topic/array-comprehensions-shorter-syntax) and > answers some of my questions, raising others. That said, I wanted to ask: > >- Why is the Comprehension Syntax in the refe

Array Comprehensions

2017-02-06 Thread Ryan Birmingham
/Reference/Operators/Array_comprehensions ). The best previous discussion on this that I found was six years old ( https://esdiscuss.org/topic/array-comprehensions-shorter-syntax) and answers some of my questions, raising others. That said, I wanted to ask: - Why is the Comprehension Syntax

Re: Array comprehensions with Spread operator

2015-04-15 Thread Jeremy Martin
Thanks, I gathered so after your response. This is why 99% of the time I wait for at least one other person to reply first, and why I *should* wait the remaining 1%... :) On Wed, Apr 15, 2015 at 12:34 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Wed, Apr 15, 2015 at 9:31 AM, Jeremy Martin

Re: Array comprehensions with Spread operator

2015-04-15 Thread Tab Atkins Jr.
On Wed, Apr 15, 2015 at 9:23 AM, monolithed monolit...@gmail.com wrote: ```js let x = [0, 1, 2]; let y = [3, 4, 5]; // Expected [ for (i of [x, y]) ...i ]; // Reality Array.prototype.concat(...[ for (x of [x, y]) i ]); // Result [0, 1, 2, 3, 4, 5] ``` Is there any discussion on

Re: Array comprehensions with Spread operator

2015-04-15 Thread Jeremy Martin
Why not just `[...x, ...y]`? On Wed, Apr 15, 2015 at 12:23 PM, monolithed monolit...@gmail.com wrote: ```js let x = [0, 1, 2]; let y = [3, 4, 5]; // Expected [ for (i of [x, y]) ...i ]; // Reality Array.prototype.concat(...[ for (x of [x, y]) i ]); // Result [0, 1, 2, 3, 4, 5]

Re: Array comprehensions with Spread operator

2015-04-15 Thread Tab Atkins Jr.
On Wed, Apr 15, 2015 at 9:31 AM, Jeremy Martin jmar...@gmail.com wrote: Why not just `[...x, ...y]`? Obviously that's a solution to the trivial example that monolithed provided, but it's not a solution to the more general problem he's alluding to, where you're doing a comprehension and want to

Array comprehensions with Spread operator

2015-04-15 Thread monolithed
```js let x = [0, 1, 2]; let y = [3, 4, 5]; // Expected [ for (i of [x, y]) ...i ]; // Reality Array.prototype.concat(...[ for (x of [x, y]) i ]); // Result [0, 1, 2, 3, 4, 5] ``` Is there any discussion on this subject? ___ es-discuss mailing

Re: Array comprehensions with Spread operator

2015-04-15 Thread Axel Rauschmayer
It’s important to keep in mind that there is no official version of array comprehensions, at the moment. So that is something to keep in mind whenever they are added to the language. I’d probably implement flatMap() and use it if I ever needed to do something like this. On 15 Apr 2015, at 18

Re: Array comprehensions with Spread operator

2015-04-15 Thread Axel Rauschmayer
you in any way, please correct. Thanks. On Wed, Apr 15, 2015 at 10:20 AM, Axel Rauschmayer a...@rauschma.de mailto:a...@rauschma.de wrote: It’s important to keep in mind that there is no official version of array comprehensions, at the moment. So that is something to keep in mind

Re: Array comprehensions with Spread operator

2015-04-15 Thread Mark S. Miller
, #a was necessary to convince me. YAGNI. Given #a, #b was sufficient. Dave, if I've misrepresented you in any way, please correct. Thanks. On Wed, Apr 15, 2015 at 10:20 AM, Axel Rauschmayer a...@rauschma.de wrote: It’s important to keep in mind that there is no official version of array

Re: Array comprehensions with Spread operator

2015-04-15 Thread liorean
On 15 April 2015 at 18:36, Jeremy Martin jmar...@gmail.com wrote: Thanks, I gathered so after your response. This is why 99% of the time I wait for at least one other person to reply first, and why I should wait the remaining 1%... :) Heck no! You asking that question clarified the problem

Re: Array comprehensions with Spread operator

2015-04-15 Thread Rick Waldron
On Wed, Apr 15, 2015 at 2:27 PM Mark S. Miller erig...@google.com wrote: Dave Herman did an excellent presentation at one of the TC39 meetings that convinced us all to drop comprehension syntax from ES6. I remember it surprised us all including, earlier Dave, which led to his presentation.

Re: Array comprehensions with Spread operator

2015-04-15 Thread monolithed
wrote: It’s important to keep in mind that there is no official version of array comprehensions, at the moment. So that is something to keep in mind whenever they are added to the language. I’d probably implement flatMap() and use it if I ever needed to do something like this. On 15 Apr 2015

Re: Array comprehensions with Spread operator

2015-04-15 Thread Mark S. Miller
On Wed, Apr 15, 2015 at 1:11 PM, monolithed monolit...@gmail.com wrote: @Mark S. Miller, Dave Herman did an excellent presentation at one of the TC39 meetings that convinced us all to drop comprehension syntax from ES6. I remember it surprised us all including, earlier Dave, which led to

Re: Array comprehensions shorter syntax (?)

2011-06-01 Thread Dmitry A. Soshnikov
On 01.06.2011 3:06, Waldemar Horwat wrote: On 05/29/11 07:00, Dmitry A. Soshnikov wrote: Yeah, and ES also supports them. It's called a generator expression; in this proposal it would look like: let squares = (x * x | x data, x 5); Ahem, that's already a parenthesized comma expression

Re: Array comprehensions shorter syntax (?)

2011-06-01 Thread David Herman
P.S.: another question I have -- is it worth and makes sense to raise a topic on considering/standardizing the pattern matching (Dave's proposal)? http://wiki.ecmascript.org/doku.php?id=strawman:pattern_matching Brendan mentioned on Twitter that it's too late (?), but IMO this proposal is

Re: Array comprehensions shorter syntax (?)

2011-06-01 Thread Dmitry A. Soshnikov
On 01.06.2011 10:57, David Herman wrote: P.S.: another question I have -- is it worth and makes sense to raise a topic on considering/standardizing the pattern matching (Dave's proposal)? http://wiki.ecmascript.org/doku.php?id=strawman:pattern_matching Brendan mentioned on Twitter that it's

Re: Array comprehensions shorter syntax (?)

2011-06-01 Thread Brendan Eich
On Jun 1, 2011, at 12:21 AM, Dmitry A. Soshnikov wrote: Ah, come on, of course I didn't compare them apples-to-apples. Just said that it's more likely that some elegant and powerful syntactic construction/sugar will be used more often than use-cases with WeakMaps and it turns out that much

Re: Array comprehensions shorter syntax (?)

2011-05-31 Thread Waldemar Horwat
On 05/29/11 07:00, Dmitry A. Soshnikov wrote: Yeah, and ES also supports them. It's called a generator expression; in this proposal it would look like: let squares = (x * x | x data, x 5); Ahem, that's already a parenthesized comma expression with operands x * x | x data and x 5.

Array comprehensions shorter syntax (?)

2011-05-29 Thread Dmitry A. Soshnikov
Hi, Don't get this proposal as a bikesheding, just an idea in case if arrow functions will win the block-functions. What about to make a sugar for Array comprehensions based also on arrow syntax? The same as in Erlang: let data = [1, 2, 3, 4, 5]; let squares = [x * x | x - data, x 3

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Jose Antonio Perez
2011/5/29 Dmitry A. Soshnikov dmitry.soshni...@gmail.com Hi, Don't get this proposal as a bikesheding, just an idea in case if arrow functions will win the block-functions. What about to make a sugar for Array comprehensions based also on arrow syntax? The same as in Erlang: let data

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Dmitry A. Soshnikov
a sugar for Array comprehensions based also on arrow syntax? The same as in Erlang: let data = [1, 2, 3, 4, 5]; let squares = [x * x | x - data, x 3]; // [16, 25] Basically you are proposing bring in Haskell's syntax for comprehensions Yeah, here I found a list of other syntax

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread François REMY
To: es-discuss@mozilla.org Subject: Re: Array comprehensions shorter syntax (?) 2011/5/29 Dmitry A. Soshnikov dmitry.soshni...@gmail.com Hi, Don't get this proposal as a bikesheding, just an idea in case if arrow functions will win the block-functions. What about to make a sugar for Array

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Dmitry A. Soshnikov
into account arrow-functions, seems arrow-comprehensions aren't so cryptic. but it’s aslo more extensible... and it don’t introduce anything new to ES Harmony. As well as current array-comprehensions; though, paren-free are better IMO. Dmitry. Please note that your syntax has to be rejected because we

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Jose Antonio Perez
2011/5/29 Dmitry A. Soshnikov dmitry.soshni...@gmail.com That's it, exactly. We always looking for a shorter sugar. Though, the main thing that the sugar shouldn't be cryptic at the same time. Probably Erlang's list comprehensions are cryptic for someone, but again, taking into account

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Jose Antonio Perez
Errata: + must be * ListComprehension : '[' Expression '|' IterableOrFilter (,IterableOrFilter)* ']' IterableOrFilter: Id '-' ArrayOrGenerator | BooleanFilter Jose. ___ es-discuss mailing list es-discuss@mozilla.org

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Brendan Eich
using bitwise-or to be parenthesized: blam = {|x = (y | z)| x*x}; But block-lambdas do not use [] where | may be an operator in a single element initialiser expression, so there's no further incompatibility. Not so with square brackets. Array comprehensions using for-in or the replacement

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Dmitry A. Soshnikov
value using bitwise-or to be parenthesized: blam = {|x = (y | z)| x*x}; But block-lambdas do not use [] where | may be an operator in a single element initialiser expression, so there's no further incompatibility. Not so with square brackets. Array comprehensions using

Re: Array comprehensions shorter syntax (?)

2011-05-29 Thread Brendan Eich
On May 29, 2011, at 12:52 PM, Dmitry A. Soshnikov wrote: P.S.: though, btw, IIRC, you said the same when an year ago I proposed arrow functions or Ruby's blocks and they were refused because of grammar reasons; today we want them to standardize ;) I mean, perhaps what seems not so needed