[#101179] Spectre Mitigations — Amel <amel.smajic@...>
Hi there!
5 messages
2020/12/01
[#101180] Re: Spectre Mitigations
— Chris Seaton <chris@...>
2020/12/01
I wouldn’t recommend using Ruby to run in-process untrusted code in the first place. Are people doing that?
[#101694] Ruby 3.0.0 Released — "NARUSE, Yui" <naruse@...>
We are pleased to announce the release of Ruby 3.0.0. From 2015 we
4 messages
2020/12/25
[ruby-core:101467] [Ruby master Feature#17277] Make Enumerator#with_index yield row and col indices for Matrix
From:
marcandre-ruby-core@...
Date:
2020-12-16 15:47:24 UTC
List:
ruby-core #101467
Issue #17277 has been updated by marcandre (Marc-Andre Lafortune).
Status changed from Assigned to Closed
Closing for lack of a viable solution
----------------------------------------
Feature #17277: Make Enumerator#with_index yield row and col indices for Matrix
https://bugs.ruby-lang.org/issues/17277#change-89242
* Author: greggzst (Grzegorz Jakubiak)
* Status: Closed
* Priority: Normal
* Assignee: marcandre (Marc-Andre Lafortune)
----------------------------------------
Given a matrix:
```ruby
matrix = Matrix[[0,2,3,4], [6,7,8,9], [1,4,5,8]]
```
You could get the row and col indices of a matrix using `Matrix#each_with_index`:
```ruby
matrix
.each_with_index { |e, row, col| p [row, col] }
[0, 0]
[0, 1]
[0, 2]
[0, 3]
[1, 0]
[1, 1]
[1, 2]
[1, 3]
[2, 0]
[2, 1]
[2, 2]
[2, 3]
```
You can chain it with other enumerators and access indices within them:
```ruby
matrix
.each_with_index
.filter_map { |e, row, col| [row, col] if e % 4 == 0}
# => [[0, 0], [0, 3], [1, 2], [2, 1], [2, 3]]
```
Meanwhile, `with_index` after `Matrix#each` returns flattened indices, not row or column indices, which does not look right:
```ruby
matrix
.each.with_index { |e, index| p index }
0
1
2
3
4
5
6
7
8
9
10
11
```
I feel we should override `with_index` for `Matrix` so it returns row and column indices.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>