ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:94796] [Ruby master Bug#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
@ 2019-09-06 10:38 ` sammomichael
  2019-09-06 13:18 ` [ruby-core:94799] " daniel
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-06 10:38 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been reported by sammomichael (Samuel Michael).

----------------------------------------
Bug #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:94799] [Ruby master Bug#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
  2019-09-06 10:38 ` [ruby-core:94796] [Ruby master Bug#16147] List Comprehensions in Ruby sammomichael
@ 2019-09-06 13:18 ` daniel
  2019-09-06 14:06 ` [ruby-core:94800] " shevegen
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: daniel @ 2019-09-06 13:18 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by Dan0042 (Daniel DeLorme).


What's wrong with existing well-established ruby idioms?

```ruby
(1..0).to_a
(1..0).select(&:even?)
(1..0).select(&:even?).map{ |x| x**2 }
(1..0).map{ |x| x**2 }
```

or in ruby 2.7:

```ruby
(1..0).to_a
(1..0).select(&:even?)
(1..0).select(&:even?).map{ _0**2 }
(1..0).map{ _0**2 }
```

or if #16120 was accepted ;-D

```ruby
(1..0).to_a
(1..0).select{.even?}
(1..0).select{.even?}.map{.**2}
(1..0).map{.**2}
```


----------------------------------------
Bug #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81420

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:94800] [Ruby master Bug#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
  2019-09-06 10:38 ` [ruby-core:94796] [Ruby master Bug#16147] List Comprehensions in Ruby sammomichael
  2019-09-06 13:18 ` [ruby-core:94799] " daniel
@ 2019-09-06 14:06 ` shevegen
  2019-09-06 16:41 ` [ruby-core:94804] [Ruby master Feature#16147] " sammomichael
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: shevegen @ 2019-09-06 14:06 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by shevegen (Robert A. Heiler).


I am not sure how serious the proposal is; but I will assume, for sake of simplicity, that
the suggestion is "real". First a minor comment - it should be filed under "features"
rather than "bug", since it is a suggestion for a change, rather than a bug, in my 
opinion; but this is an aside.

Next, I will briefly comment on this statement:

> Ruby has a for...in loop that is rarely used but could possibly be repurposed.

Let's for a moment briefly ignore whether people use the for loop or not (they
actually do; but let's ignore this for the moment).

Matz has said several times before that the transition from ruby 2.0 (2.x) to
3.0 will not be anywhere near as "problematic" as 1.8.x to 2.x was. So for
this reason alone, I believe that IF this were to be approved, it would have
to come way after 3.0, possibly 3.1 at earliest or even after that - so I
guess a few years from this point. (Ruby 3.0 will be released next year,
so we don't have that much time really; 15 months or so, give or take.)

You also wrote that the "for" loop is rarely used. Well, this is partially
true. I myself use almost exclusively .each and loop {}. But - I know of
other people who use "for" quite a bit, in particular when you have like
a matrix and iterate through it; in this case I can understand that a for
loop is used, even if I personally prefer .each and loop {}. So I am not
sure if your general comment is correct.

The philosophy of "more than one way to do it" also means that the "lesser
ways", that is, used more sporadically, will not necessarily be removed
merely because most ruby users may not use it. There are many other examples
here, such as @@class_variables. I don't use the latter myself, and would
rather see them go, but there are others who use class variables just fine,
even in the ruby code base (the recent rewrite of irb for example has some
class variables). So I think this is not a good metric in regards to 
"adoption". But this is also not the main issue here.

The next comment to make .... hmm. List comprehensions remind me of python.

I use both ruby and python fine, but python feels a bit strange, in many
ways. Including python's OOP way (I absolutely hate explicit self by far
the most; mandatory indent is so minor compared to having to pass self
to every function/method in a class). IMO, ruby's way to filter is a
LOT more natural and easier to both understand and read than are python's
list comprehensions.

Granted, you were not confining your suggestion to python alone, so there
may be other list comprehensions that are succinct and elegant. I don't
really see them in the proposal per se, but perhaps they exist; I don't
know. I think that ruby's existing ways are very succinct, though.
Ultimately I don't think ruby needs list comprehensions, most definitely
not the pythonic list comprehensions.

You gave an example as-is in ruby:

    S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1] # [0, 4, 8, 12, 16]

Off the top of my mind, this would be better, in my opinion:

    (0..16).select {|entry| entry % 4 == 0} => [0, 4, 8, 12, 16]

I am sure there are many other ways (Dan0042 provided more examples),
but IMO, the latter is so much more readable than the first variant,
so I don't think there is any real improvement.

You gave more examples such as:

    c = -> x do $*.clear             
      if x['if'] && x[0] != 'f' . 

I don't really know what this is. It almost looks as if there was an
attempt made to make this less readable.

Anyway you only have to convince matz, but I am not sure if the 
proposal as it presently is has a good chance for implementation;
there seem to be too many trade offs associated with it in its
current form. Or perhaps there is some additional reasoning or
advantage missing; I am not quite seeing the improvement or the
stated need, to be honest.

Best luck to you nonetheless.

----------------------------------------
Bug #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81421

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:94804] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-09-06 14:06 ` [ruby-core:94800] " shevegen
@ 2019-09-06 16:41 ` sammomichael
  2019-09-06 16:44 ` [ruby-core:94805] " sammomichael
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-06 16:41 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).

Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN)
Tracker changed from Bug to Feature

shevegen (Robert A. Heiler) wrote:
> I am not sure how serious the proposal is; but I will assume, for sake of simplicity, that
> the suggestion is "real". First a minor comment - it should be filed under "features"
> rather than "bug", since it is a suggestion for a change, rather than a bug, in my 
> opinion; but this is an aside.
> 
> Next, I will briefly comment on this statement:
> 
> > Ruby has a for...in loop that is rarely used but could possibly be repurposed.
> 
> Let's for a moment briefly ignore whether people use the for loop or not (they
> actually do; but let's ignore this for the moment).
> 
> Matz has said several times before that the transition from ruby 2.0 (2.x) to
> 3.0 will not be anywhere near as "problematic" as 1.8.x to 2.x was. So for
> this reason alone, I believe that IF this were to be approved, it would have
> to come way after 3.0, possibly 3.1 at earliest or even after that - so I
> guess a few years from this point. (Ruby 3.0 will be released next year,
> so we don't have that much time really; 15 months or so, give or take.)
> 
> You also wrote that the "for" loop is rarely used. Well, this is partially
> true. I myself use almost exclusively .each and loop {}. But - I know of
> other people who use "for" quite a bit, in particular when you have like
> a matrix and iterate through it; in this case I can understand that a for
> loop is used, even if I personally prefer .each and loop {}. So I am not
> sure if your general comment is correct.
> 
> I assume that one reason why a for loop exists, and also other aliases,
> such as .map <- -> .collect, and as to why ruby is multi-paradigm, was
> that matz wanted to make ruby convenient to use for people with different
> background. Ruby itself has incorporated useful ideas and paradigms from
> other languages too. (My personal opinion is that, by far, the strongest
> point of ruby, in regards to philosophies, is its OOP-centric nature, but
> you may disagree. People use ruby in different ways, though. Some of the
> ruby code looks quite alien; and matz has said sometimes, in the past,
> that he was sometimes surprised to see how people use ruby.)
> 
> The philosophy of "more than one way to do it" also means that the "lesser
> ways", that is, used more sporadically, will not necessarily be removed
> merely because most ruby users may not use it. There are many other examples
> here, such as @@class_variables. I don't use the latter myself, and would
> rather see them go, but there are others who use class variables just fine,
> even in the ruby code base (the recent rewrite of irb for example has some
> class variables). So I think this is not a good metric in regards to 
> "adoption". But this is also not the main issue here.
> 
> The next comment to make .... hmm. List comprehensions remind me of python.
> 
> I use both ruby and python fine, but python feels a bit strange, in many
> ways. Including python's OOP way (I absolutely hate explicit self by far
> the most; mandatory indent is so minor compared to having to pass self
> to every function/method in a class). IMO, ruby's way to filter is a
> LOT more natural and easier to both understand and read than are python's
> list comprehensions.
> 
> Granted, you were not confining your suggestion to python alone, so there
> may be other list comprehensions that are succinct and elegant. I don't
> really see them in the proposal per se, but perhaps they exist; I don't
> know. I think that ruby's existing ways are very succinct, though.
> Ultimately I don't think ruby needs list comprehensions, most definitely
> not the pythonic list comprehensions.
> 
> You gave an example as-is in ruby:
> 
>     S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1] # [0, 4, 8, 12, 16]
> 
> Off the top of my mind, this would be better, in my opinion:
> 
>     (0..16).select {|entry| entry % 4 == 0} => [0, 4, 8, 12, 16]
> 
> I am sure there are many other ways (Dan0042 provided more examples),
> but IMO, the latter is so much more readable than the first variant,
> so I don't think there is any real improvement.
> 
> You gave more examples such as:
> 
>     c = -> x do $*.clear             
>       if x['if'] && x[0] != 'f' . 
> 
> I don't really know what this is. It almost looks as if there was an
> attempt made to make this less readable.
> 
> Anyway you only have to convince matz, but I am not sure if the 
> proposal as it presently is has a good chance for implementation;
> there seem to be too many trade offs associated with it in its
> current form. Or perhaps there is some additional reasoning or
> advantage missing; I am not quite seeing the improvement or the
> stated need, to be honest.
> 
> Best luck to you nonetheless.

There is nothing wrong with the current ruby syntax of using enumerables such as map/select/filter_map to generate the same type of list. But as you said ruby is all about many ways of doing things. And as many languages offer some version of this feature (Julia, Python, CoffeeScript, etc.)  it could be beneficial for ruby to incorporate its own variation. There is something natural and refreshing about using pure mathematical set builder notation with keywords for...in to generate an array.`[*1..10].filter_map{@1**2 if @1.even?} vs [x**2 for x in 1..10 if x.even?]` The second version has less symbols, less keystrokes and is more human readable for beginners imo. Also I didn't mean to suggest that we retire the normal for...in loop (which I use myself) to break older code or that nobody ever uses it, but I am suggesting that we extend it if possible, just as was done with making "in" the keyword for the new pattern matching system.   

[[https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(list_comprehension)]]

Dan0042 (Daniel DeLorme) wrote:
> What's wrong with existing well-established object-oriented ruby idioms?
> 
> ```ruby
> (1..10).to_a
> (1..10).select(&:even?)
> (1..10).select(&:even?).map{ |x| x**2 }
> (1..10).map{ |x| x**2 }
> ```
> 
> or in ruby 2.7:
> 
> ```ruby
> (1..10).to_a
> (1..10).select(&:even?)
> (1..10).select(&:even?).map{ _0**2 }
> (1..10).map{ _0**2 }
> ```
> 
> or if #16120 was accepted ;-D
> 
> ```ruby
> (1..10).to_a
> (1..10).select{.even?}
> (1..10).select{.even?}.map{.**2}
> (1..10).map{.**2}
> ```




----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81426

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:94805] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-09-06 16:41 ` [ruby-core:94804] [Ruby master Feature#16147] " sammomichael
@ 2019-09-06 16:44 ` sammomichael
  2019-09-06 17:28 ` [ruby-core:94807] " sammomichael
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-06 16:44 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


There is nothing wrong with the current ruby syntax of using enumerables such as map/select/filter_map to generate the same type of list. But as you said ruby is all about many ways of doing things. And as many languages offer some version of this feature (Julia, Python, CoffeeScript, etc.) it could be beneficial for ruby to incorporate its own variation. There is something natural and refreshing about using pure mathematical set builder notation with keywords for...in to generate an array. `[*1..10].filter_map{@1**2 if @1.even?}` vs `[x**2 for x in 1..10 if x.even?]`  The second version has less symbols, less keystrokes and is more human readable for beginners imo. Also I didn't mean to suggest that we retire the normal for...in loop (which I use myself) to break older code or that nobody ever uses it, but I am suggesting that we extend it if possible, just as was done with making "in" the keyword for the new pattern matching system.

----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81427

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:94807] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-09-06 16:44 ` [ruby-core:94805] " sammomichael
@ 2019-09-06 17:28 ` sammomichael
  2019-09-21 21:46 ` [ruby-core:95026] " sammomichael
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-06 17:28 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


sammomichael (Samuel Michael) wrote:
> shevegen (Robert A. Heiler) wrote:
> > I am not sure how serious the proposal is; but I will assume, for sake of simplicity, that
> > the suggestion is "real". First a minor comment - it should be filed under "features"
> > rather than "bug", since it is a suggestion for a change, rather than a bug, in my 
> > opinion; but this is an aside.

Yes it is real, and yes, I should have changed it to be a feature and not a bug

> > Next, I will briefly comment on this statement:
> > 
> > > Ruby has a for...in loop that is rarely used but could possibly be repurposed.
> > 
> > Let's for a moment briefly ignore whether people use the for loop or not (they
> > actually do; but let's ignore this for the moment).

I use it too, that is why I said "rarely" rather than never or fully deprecated. It has to be admitted it is less common in Ruby vernacular than in other languages. Also I never said intended that it break compatibility with earlier versions or that we wouldn't still be able to use for loop, rather to extend those keywords for an additional use of generating a list comprehension to give an alternate option to filter_map. Obviously filter_mapping was considered important enough to add a enumerable specifically for that, I am suggesting we offering an additional and alternate notation using [for..in] inside of brackets, obviously the final syntax would depend on the parser and how it would be easiest to modify without breaking compatibility with previous versions. 

> > Matz has said several times before that the transition from ruby 2.0 (2.x) to
> > 3.0 will not be anywhere near as "problematic" as 1.8.x to 2.x was. So for
> > this reason alone, I believe that IF this were to be approved, it would have
> > to come way after 3.0, possibly 3.1 at earliest or even after that - so I
> > guess a few years from this point. (Ruby 3.0 will be released next year,
> > so we don't have that much time really; 15 months or so, give or take.)
> > 

> > You also wrote that the "for" loop is rarely used. Well, this is partially
> > true. I myself use almost exclusively .each and loop {}. But - I know of
> > other people who use "for" quite a bit, in particular when you have like
> > a matrix and iterate through it; in this case I can understand that a for
> > loop is used, even if I personally prefer .each and loop {}. So I am not
> > sure if your general comment is correct.

A few years is fine by me, IF it were to be approved, that is a reasonable trajectory...

> > I assume that one reason why a for loop exists, and also other aliases,
> > such as .map <- -> .collect, and as to why ruby is multi-paradigm, was
> > that matz wanted to make ruby convenient to use for people with different
> > background. Ruby itself has incorporated useful ideas and paradigms from
> > other languages too. (My personal opinion is that, by far, the strongest
> > point of ruby, in regards to philosophies, is its OOP-centric nature, but
> > you may disagree. People use ruby in different ways, though. Some of the
> > ruby code looks quite alien; and matz has said sometimes, in the past,
> > that he was sometimes surprised to see how people use ruby.)
> > 
> > The philosophy of "more than one way to do it" also means that the "lesser
> > ways", that is, used more sporadically, will not necessarily be removed
> > merely because most ruby users may not use it. There are many other examples
> > here, such as @@class_variables. I don't use the latter myself, and would
> > rather see them go, but there are others who use class variables just fine,
> > even in the ruby code base (the recent rewrite of irb for example has some
> > class variables). So I think this is not a good metric in regards to 
> > "adoption". But this is also not the main issue here.
> > 
> > The next comment to make .... hmm. List comprehensions remind me of python.
> > 
> > I use both ruby and python fine, but python feels a bit strange, in many
> > ways. Including python's OOP way (I absolutely hate explicit self by far
> > the most; mandatory indent is so minor compared to having to pass self
> > to every function/method in a class). IMO, ruby's way to filter is a
> > LOT more natural and easier to both understand and read than are python's
> > list comprehensions.


> > 
> > Granted, you were not confining your suggestion to python alone, so there
> > may be other list comprehensions that are succinct and elegant. I don't
> > really see them in the proposal per se, but perhaps they exist; I don't
> > know. I think that ruby's existing ways are very succinct, though.
> > Ultimately I don't think ruby needs list comprehensions, most definitely
> > not the pythonic list comprehensions.
> > 
> > You gave an example as-is in ruby:
> > 
> >     S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1] # [0, 4, 8, 12, 16]
> > 
> > Off the top of my mind, this would be better, in my opinion:
> > 
> >     (0..16).select {|entry| entry % 4 == 0} => [0, 4, 8, 12, 16]
> > 
> > I am sure there are many other ways (Dan0042 provided more examples),
> > but IMO, the latter is so much more readable than the first variant,
> > so I don't think there is any real improvement.
> > 
> > You gave more examples such as:
> > 
> >     c = -> x do $*.clear             
> >       if x['if'] && x[0] != 'f' . 
> > 
> > I don't really know what this is. It almost looks as if there was an
> > attempt made to make this less readable.

This is the lambda used to evaluate a list comprehension string and return an array in the examples below it.
> > 
> > Anyway you only have to convince matz, but I am not sure if the 
> > proposal as it presently is has a good chance for implementation;
> > there seem to be too many trade offs associated with it in its
> > current form. Or perhaps there is some additional reasoning or
> > advantage missing; I am not quite seeing the improvement or the
> > stated need, to be honest.
> > 
> > Best luck to you nonetheless.
> 

> 
> [[https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(list_comprehension)]]
> 
> Dan0042 (Daniel DeLorme) wrote:
> > What's wrong with existing well-established object-oriented ruby idioms?
> > 
> > ```ruby
> > (1..10).to_a
> > (1..10).select(&:even?)
> > (1..10).select(&:even?).map{ |x| x**2 }
> > (1..10).map{ |x| x**2 }
> > ```
> > 
> > or in ruby 2.7:
> > 
> > ```ruby
> > (1..10).to_a
> > (1..10).select(&:even?)
> > (1..10).select(&:even?).map{ _0**2 }
> > (1..10).map{ _0**2 }
> > ```
> > 
> > or if #16120 was accepted ;-D
> > 
> > ```ruby
> > (1..10).to_a
> > (1..10).select{.even?}
> > (1..10).select{.even?}.map{.**2}
> > (1..10).map{.**2}
> > ```



----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81428

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95026] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-09-06 17:28 ` [ruby-core:94807] " sammomichael
@ 2019-09-21 21:46 ` sammomichael
  2019-09-22 10:09 ` [ruby-core:95031] " nobu
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-21 21:46 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


In reiteration of my main points, Ruby is a dynamic multi-paradigm language which should when possible embrace a variety of modes to achieve the same result.    

SO what would be the benefits of list comprehension in Ruby and what would it look like? 

1. Creating an array with only [] square brackets is fun and makes intuitive sense for beginners
2. "For .. in .." syntax is succinct, flexible, and has a good spoken rhythm/easy to verbalize
3. Easier for users of other languages to assimilate into Ruby as they don't need to know all our enumerable library right away.

Ruby already has functioning list comprehension syntax but it could be optimized:

[for x in 1..10 do x**2 if x%2==0 end] # this is Ruby but we can't capture the value 
[for x in 1..10; x**2 if x.even? end] # since 2.7 Ruby it would also be better if it called Filter_Map under the hood instead of each

# proposal to use some syntax to use a splat or additional indicator to allow a smoother shorthand for list comprehensions

[for x in 1..10 do x**2 if x.even? end] #=> 1..10  (normal Ruby)

# below we propose a syntax in which we splat the for loop to return the stored result not the caller

[*for x in 1..10 do x**2 if x.even? end] #=> [4, 16, 36, 64, 100] 

# under the hood this could be syntactic sugar for 

(1..10).filter_map{@1**2 if @1.even?}  #=> [4, 16, 36, 64, 100] 

# the key differences to notice. although there are less keystrokes with filter_map, you had to know the method name, and the exact arrangement of parentheses and curly braces, and whether to use a block or numbered parameter. If you decided to use pre-2.7 ruby you would have said:

(1..10).filter_map{|x|x**2 if x.even?}

vs with proposed list syntax:

[*for x in 1..10; x**2 if x.even? end] 

# I think both could and should be standard ruby syntax of achieving the same result of quickly generating a filter mapped array of the given elements.







----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81654

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95031] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-09-21 21:46 ` [ruby-core:95026] " sammomichael
@ 2019-09-22 10:09 ` nobu
  2019-09-22 16:47 ` [ruby-core:95035] " eregontp
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2019-09-22 10:09 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by nobu (Nobuyoshi Nakada).


sammomichael (Samuel Michael) wrote:
> ```ruby
> [for x in 1..10 do x**2 if x.even? end] #=> 1..10  (normal Ruby)
> ```

It is an `Array` from 0 to 10 now.

> below we propose a syntax in which we splat the for loop to return the stored result not the caller
> 
> ```ruby
> [*for x in 1..10 do x**2 if x.even? end] #=> [4, 16, 36, 64, 100]
> ```

Obviously the latter result conflicts with the former.
Which result do you expect from the following code?

```ruby
a = for x in 1..10 do x**2 if x.even? end
[*a] #=> ????

[*(for x in 1..10 do x**2 if x.even? end)] #=> ????
```


----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81661

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95035] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2019-09-22 10:09 ` [ruby-core:95031] " nobu
@ 2019-09-22 16:47 ` eregontp
  2019-09-23 21:16 ` [ruby-core:95047] " sammomichael
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: eregontp @ 2019-09-22 16:47 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by Eregon (Benoit Daloze).


Just my opinion: I don't think we should have list comprehensions in Ruby.

They are just a small subset of the far more powerful Enumerable methods, and IMHO are often less readable (e.g., nested list comprehensions in Python are what I would call unreadable).
Also, I think they basically don't scale, they might look nice for small expressions, but as soon as it becomes bigger it's no longer possible to use the list comprehension syntax.
So I think it's better to use map/select/filter_map directly.

----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81666

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95047] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2019-09-22 16:47 ` [ruby-core:95035] " eregontp
@ 2019-09-23 21:16 ` sammomichael
  2019-09-23 22:06 ` [ruby-core:95049] " sammomichael
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-23 21:16 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


nobu (Nobuyoshi Nakada) wrote:
> sammomichael (Samuel Michael) wrote:
> > ```ruby
> > [for x in 1..10 do x**2 if x.even? end] #=> 1..10  (normal Ruby)
> > ```
> 
> It is an `Array` from 0 to 10 now. Correct thanks I should have wrote [1..10]
> 
> > below we propose a syntax in which we splat the for loop to return the stored result not the caller
> > 
> > ```ruby
> > [*for x in 1..10 do x**2 if x.even? end] #=> [4, 16, 36, 64, 100]
> > ```
> 
> Obviously the latter result conflicts with the former.
> Which result do you expect from the following code?
 Hi, I was suggesting a splat operator as one way to create a special syntax, under the hood instead of calling each method it would treat this as a filter map, map, or filter operation, and return the result in place. My intention is to create a flexible alternative syntax to enumerable syntax or using external iteration to do the same thing. Of course it doesn't have to be a splat, just some way to indicate you are invoking the shorthand for Ruby list comprehension, not using Ruby traditional for (.each) loop. Splat could be interpreted here as spreading the values from the block into a new array.

> 
> ```ruby
> a = for x in 1..10 do x**2 if x.even? end
> [*a] #=> [4, 16, 36, 64, 100] a = 1..10 => [1,2,3,4,5,6,7,8,9,10]  for loop results in 1..10 and spreads out to an array
the new syntax will not work on ranges only can be declared within [] square brackets at the time of invocation

> [*(for x in 1..10 do x**2 if x.even? end)] #=> [1,2,3,4,5,6,7,8,9,10] here the expression in parenthesis would resolve to range 1..10 and be splatted to an array
I'm not sure if there is a reason to do this though, but I am open to other opinions if there is something better that should happen
> ```



----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81678

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95049] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2019-09-23 21:16 ` [ruby-core:95047] " sammomichael
@ 2019-09-23 22:06 ` sammomichael
  2019-09-29  2:26 ` [ruby-core:95144] " sammomichael
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-23 22:06 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


Eregon (Benoit Daloze) wrote:
> Just my opinion: I don't think we should have list comprehensions in Ruby.

Thanks I appreciate the feedback! 

> They are just a small subset of the far more powerful Enumerable methods, and IMHO are often less readable (e.g., nested list comprehensions in Python are what I would call unreadable).
> Also, I think they basically don't scale, they might look nice for small expressions, but as soon as it becomes bigger it's no longer possible to use the list comprehension syntax.
> So I think it's better to use map/select/filter_map directly.

You have some very good points! Nested comprehensions can get pretty gnarly. Still, I have heard anecdotally from a lot of professional developers that Python list comprehensions are useful to them. Julia inventors though well enough of them to include them in their new language, and a bunch of other languages have some variation as well. I tried to point out some of the benefits in my list above, but basically:
1. a versatile tool, a third (syntax)option alongside of enumerable methods for array generation
2. flexible and easy for beginners to understand 
3. square brackets make the array return explicit 
 


----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81679

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95144] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2019-09-23 22:06 ` [ruby-core:95049] " sammomichael
@ 2019-09-29  2:26 ` sammomichael
  2019-10-03 17:57 ` [ruby-core:95200] " sammomichael
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-09-29  2:26 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


[[https://github.com/SammoMichael/Ruby_List_Comprehension/]]

Here is a gem to give a better idea what I mean. 

Instructions: 
gem install ruby_list_comprehension

require 'ruby_list_comprehension'

l - ListComprehension.new (call with class instance and bracketed string to invoke lambda) l + [ ] + 'for x in 1..10 do x' (optional map/filter condition)

l['for x in 1..10 do x + 5 || x - 3 if x != 3 end'] #=> [6, 7, 9, 10, 11, 12, 13, 14, 15]
l['for x in Set.new([1,2,2,3,4,5]) do x.to_s if x != 2'] #=> ["1", "3", "4", "5"]

if you would like to try out a prototype I would appreciate feedback 

----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81783

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95200] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2019-09-29  2:26 ` [ruby-core:95144] " sammomichael
@ 2019-10-03 17:57 ` sammomichael
  2019-10-04  0:41 ` [ruby-core:95213] " sammomichael
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-10-03 17:57 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


sammomichael (Samuel Michael) wrote:
> ## ruby_list_comprehension gem documentation
> https://github.com/SammoMichael/Ruby_List_Comprehension
> ## ruby_list_comprehension gem page
> https://rubygems.org/gems/ruby_list_comprehension
> Here is a gem to give a better idea what I mean. 
> 
> Instructions: 
> gem install ruby_list_comprehension
> 
> `require 'ruby_list_comprehension'`
> 
> `l - ListComprehension.new`
> 
> ` l[for x in 1..10 do x end] (optional map/filter condition)`
> 
> `l[for x in 1..10 do x + 5 || x - 3 if x != 3 end] #=> [6, 7, 9, 10, 11, 12, 13, 14, 15]`
> 
> `l[for x in Set.new([1,2,2,3,4,5]) do x.to_s if x != 2 end] #=> ["1", "3", "4", "5"]`
> 
> if you would like to try out a prototype I would appreciate feedback



----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81876

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95213] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2019-10-03 17:57 ` [ruby-core:95200] " sammomichael
@ 2019-10-04  0:41 ` sammomichael
  2019-10-07 13:01 ` [ruby-core:95259] " sammomichael
  2019-10-07 18:35 ` [ruby-core:95262] " sammomichael
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-10-04  0:41 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


sammomichael (Samuel Michael) wrote:
> sammomichael (Samuel Michael) wrote:
> > ## ruby_list_comprehension gem documentation
> > https://github.com/SammoMichael/Ruby_List_Comprehension
> > ## ruby_list_comprehension gem page
> > https://rubygems.org/gems/ruby_list_comprehension
> > Here is a gem to give a better idea what I mean. 
> > [![Gem Version](https://badge.fury.io/rb/ruby_list_comprehension.svg)](https://badge.fury.io/rb/ruby_list_comprehension)
> > Instructions: 
> > gem install ruby_list_comprehension
> > 
> > `require 'ruby_list_comprehension'`
> > 
> > `l - ListComprehension.new`
> > 
> > ` l[for x in 1..10 do x end] (optional map/filter condition)`
> > 
> > `l[for x in 1..10 do x + 5 || x - 3 if x != 3 end] #=> [6, 7, 9, 10, 11, 12, 13, 14, 15]`
> > 
> > `l[for x in Set.new([1,2,2,3,4,5]) do x.to_s if x != 2 end] #=> ["1", "3", "4", "5"]`
> > 
> > if you would like to try out a prototype I would appreciate feedback



----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81887

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95259] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2019-10-04  0:41 ` [ruby-core:95213] " sammomichael
@ 2019-10-07 13:01 ` sammomichael
  2019-10-07 18:35 ` [ruby-core:95262] " sammomichael
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-10-07 13:01 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


I also have added rudimentary support for nested comprehensions. 

# Build Matrix from nested loop
`p $l[[for x in 1..10 do end], for x in 2..20 do x end] ` #=> does (1..10).map{(2..20).map{|x|x}

# Flatten Matrix with nested loop
`p $l[for x in 1..10 do for x in 2..20 do x end end]` #=> does (1..10).map{(2..20).map{|x|x}.flatten


----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81937

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ruby-core:95262] [Ruby master Feature#16147] List Comprehensions in Ruby
       [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
                   ` (14 preceding siblings ...)
  2019-10-07 13:01 ` [ruby-core:95259] " sammomichael
@ 2019-10-07 18:35 ` sammomichael
  15 siblings, 0 replies; 16+ messages in thread
From: sammomichael @ 2019-10-07 18:35 UTC (permalink / raw)
  To: ruby-core

Issue #16147 has been updated by sammomichael (Samuel Michael).


sammomichael (Samuel Michael) wrote:
> I also have added rudimentary support for nested comprehensions. 
>  
   

> # Build Matrix from nested loop
> `$l[[for x in 1..10 do end], for x in 2..20 do x end] ` #=> does (1..10).map{(2..20).map{|x|x}
> `$l[[for j in 1..5 do end], for i in 1..5 do end] #=> (1..5).map{(1..5).map(&:itself)}`
   
> # Flatten Matrix with nested loop
> `$l[for x in 1..10 do for x in 2..20 do x end end]` #=> does (1..10).map{(2..20).map{|x|x}.flatten`
   `$l[for x in 1..10 do for x in 2..20 do x+2 end end]` #=> [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]



----------------------------------------
Feature #16147: List Comprehensions in Ruby
https://bugs.ruby-lang.org/issues/16147#change-81939

* Author: sammomichael (Samuel Michael)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## List comprehensions are present in many languages and programmers are quite fond of their simplicity and power. Add to that the fact that Ruby has a for...in loop that is rarely used but could possibly be repurposed. 

### Currently we can already do a hack like this to make Ruby support list comprehension syntax:

``` ruby
S = [for x in 0...9 do $* << x*2 if x.even? end, $*][1]
# [0, 4, 8, 12, 16]
```

Still, it would be far nicer if the for...in loop would return the desired array automatically, this is one way to approach that taking advantage of lambda bracket invocation syntax:

``` ruby
c = -> x do $*.clear             
  if x['if'] && x[0] != 'f' .  
    y = x[0...x.index('for')]    
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif x['if'] && x[0] == 'f'
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << x")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  elsif !x['if'] && x[0] != 'f'
    y = x[0...x.index('for')]
    x = x[x.index('for')..-1]
    (x.insert(x.index(x.split[3]) + x.split[3].length, " do $* << #{y}")
    x.insert(x.length, "end; $*")
    eval(x)
    $*)
  else
    eval(x.split[3]).to_a
  end
end 

```

so basically we are converting a string to proper ruby syntax for loop then we can use python syntax in a string to do:

``` ruby

c['for x in 1..10']
c['for x in 1..10 if x.even?']
c['x**2 for x in 1..10 if x.even?']
c['x**2 for x in 1..10']

# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# [2, 4, 6, 8, 10]
# [4, 16, 36, 64, 100]
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-10-07 18:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16147.20190906103822@ruby-lang.org>
2019-09-06 10:38 ` [ruby-core:94796] [Ruby master Bug#16147] List Comprehensions in Ruby sammomichael
2019-09-06 13:18 ` [ruby-core:94799] " daniel
2019-09-06 14:06 ` [ruby-core:94800] " shevegen
2019-09-06 16:41 ` [ruby-core:94804] [Ruby master Feature#16147] " sammomichael
2019-09-06 16:44 ` [ruby-core:94805] " sammomichael
2019-09-06 17:28 ` [ruby-core:94807] " sammomichael
2019-09-21 21:46 ` [ruby-core:95026] " sammomichael
2019-09-22 10:09 ` [ruby-core:95031] " nobu
2019-09-22 16:47 ` [ruby-core:95035] " eregontp
2019-09-23 21:16 ` [ruby-core:95047] " sammomichael
2019-09-23 22:06 ` [ruby-core:95049] " sammomichael
2019-09-29  2:26 ` [ruby-core:95144] " sammomichael
2019-10-03 17:57 ` [ruby-core:95200] " sammomichael
2019-10-04  0:41 ` [ruby-core:95213] " sammomichael
2019-10-07 13:01 ` [ruby-core:95259] " sammomichael
2019-10-07 18:35 ` [ruby-core:95262] " sammomichael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).