[#84867] [Ruby trunk Bug#14357] thread_safe tests suite segfaults — v.ondruch@...

Issue #14357 has been reported by vo.x (Vit Ondruch).

11 messages 2018/01/15
[#85364] Re: [Ruby trunk Bug#14357] thread_safe tests suite segfaults — Eric Wong <normalperson@...> 2018/02/03

[email protected] wrote:

[#84980] [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — hsbt@...

Issue #13618 has been updated by hsbt (Hiroshi SHIBATA).

10 messages 2018/01/23
[#85012] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — Eric Wong <normalperson@...> 2018/01/23

[email protected] wrote:

[ruby-core:85195] [Ruby trunk Feature#14399] Add Enumerable#product

From: jzakiya@...
Date: 2018-01-28 21:46:41 UTC
List: ruby-core #85195
Issue #14399 has been updated by jzakiya (Jabari Zakiya).


According to the thread you provided the initial suggested name was `Array#product_set`
which was shortened to the current `Array#product`. Its proposed intent was to provide
combination groups of set-like items, and not as an arithmetic operation.

As was stated previously, naming things is Hard!, especially when you can't anticipate all
the unintended consequences.

I think [Crystal](https://crystal-lang.org/api/0.24.1/Enumerable.html) has gotten it correct for this, having both `Enumerable#product` and
`Enumerable#sum` methods. I suspect the overwhelming majority of programmers|users 
coming to Ruby would expects the following behavior too.

```
[2,3,5,7].sum => 17        # the result of adding all the array elements

[2,3,5,7].product => 210   # the result of multiplying all the array elements
```

----------------------------------------
Feature #14399: Add Enumerable#product
https://bugs.ruby-lang.org/issues/14399#change-69941

* Author: jzakiya (Jabari Zakiya)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
For similar reasons for creating `Enumerable#sum` a companion method
`Enumerable#product` is also very useful. Taking the product of
numbers in arrays is a common operation in many numerical algorithms,
especially in number theory and cryptography, and its optimization in
Ruby will make it more conducive to math heavy algorithms and tasks.

This

```
> [2,3,5,7].reduce(:*) => 210
```

can be optimized to this

```
> [2,3,5,7].product => 210
```

It should also allow an initial value

```
> [2,3,5,7].product(2) => 420

> [2,3,5,7].product(0.5) => 105
```
Crystal already has this `method`.



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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next