ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:50920] [Ruby master Feature#3647] Array#sample(n, replace=false)
       [not found] <redmine.issue-3647.20100803131329.482@ruby-lang.org>
@ 2020-03-10  4:58 ` nobu
  2020-03-10 10:18 ` [ruby-dev:50921] " sawadatsuyoshi
  2020-03-11  2:09 ` [ruby-dev:50922] " nobu
  2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2020-03-10  4:58 UTC (permalink / raw)
  To: ruby-dev

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

Description updated

https://github.com/ruby/ruby/pull/2955
The option name is `replace` for now.

----------------------------------------
Feature #3647: Array#sample(n, replace=false)
https://bugs.ruby-lang.org/issues/3647#change-84567

* Author: mrkn (Kenta Murata)
* Status: Feedback
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
----------------------------------------
`Array#sample` does not support sampling with replacement directly, so we must write codes like the following to obtain samples with replacement.

```ruby
samples_with_replacement = n.times.map { source.sample }
```
 
If `Array#sample` has the argument for switching with/without replacement, we can write it as follow.
 
```ruby
samples_with_replacement = source.sample(n, true)
```
 
The patch was attached.  Please consider to merge.



---Files--------------------------------
array_sample_with_replace.patch (3.64 KB)
array_sample_with_replace_hash.patch (4.35 KB)
array_sample_shuffle.patch (9.62 KB)


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

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

* [ruby-dev:50921] [Ruby master Feature#3647] Array#sample(n, replace=false)
       [not found] <redmine.issue-3647.20100803131329.482@ruby-lang.org>
  2020-03-10  4:58 ` [ruby-dev:50920] [Ruby master Feature#3647] Array#sample(n, replace=false) nobu
@ 2020-03-10 10:18 ` sawadatsuyoshi
  2020-03-11  2:09 ` [ruby-dev:50922] " nobu
  2 siblings, 0 replies; 3+ messages in thread
From: sawadatsuyoshi @ 2020-03-10 10:18 UTC (permalink / raw)
  To: ruby-dev

Issue #3647 has been updated by sawa (Tsuyoshi Sawada).


`Array#repeated_combination`, `Array#repeated_permutation` が既にあり、本件はこれと類似した内容なので、一貫性の観点から `Array#repeated_sample` というメソッド名が良いと思います。

----------------------------------------
Feature #3647: Array#sample(n, replace=false)
https://bugs.ruby-lang.org/issues/3647#change-84568

* Author: mrkn (Kenta Murata)
* Status: Feedback
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
----------------------------------------
`Array#sample` does not support sampling with replacement directly, so we must write codes like the following to obtain samples with replacement.

```ruby
samples_with_replacement = n.times.map { source.sample }
```
 
If `Array#sample` has the argument for switching with/without replacement, we can write it as follow.
 
```ruby
samples_with_replacement = source.sample(n, true)
```
 
The patch was attached.  Please consider to merge.



---Files--------------------------------
array_sample_with_replace.patch (3.64 KB)
array_sample_with_replace_hash.patch (4.35 KB)
array_sample_shuffle.patch (9.62 KB)


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

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

* [ruby-dev:50922] [Ruby master Feature#3647] Array#sample(n, replace=false)
       [not found] <redmine.issue-3647.20100803131329.482@ruby-lang.org>
  2020-03-10  4:58 ` [ruby-dev:50920] [Ruby master Feature#3647] Array#sample(n, replace=false) nobu
  2020-03-10 10:18 ` [ruby-dev:50921] " sawadatsuyoshi
@ 2020-03-11  2:09 ` nobu
  2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2020-03-11  2:09 UTC (permalink / raw)
  To: ruby-dev

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


https://github.com/ruby/ruby/pull/2956

----------------------------------------
Feature #3647: Array#sample(n, replace=false)
https://bugs.ruby-lang.org/issues/3647#change-84586

* Author: mrkn (Kenta Murata)
* Status: Feedback
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
----------------------------------------
`Array#sample` does not support sampling with replacement directly, so we must write codes like the following to obtain samples with replacement.

```ruby
samples_with_replacement = n.times.map { source.sample }
```
 
If `Array#sample` has the argument for switching with/without replacement, we can write it as follow.
 
```ruby
samples_with_replacement = source.sample(n, true)
```
 
The patch was attached.  Please consider to merge.



---Files--------------------------------
array_sample_with_replace.patch (3.64 KB)
array_sample_with_replace_hash.patch (4.35 KB)
array_sample_shuffle.patch (9.62 KB)


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

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

end of thread, other threads:[~2020-03-11  2:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-3647.20100803131329.482@ruby-lang.org>
2020-03-10  4:58 ` [ruby-dev:50920] [Ruby master Feature#3647] Array#sample(n, replace=false) nobu
2020-03-10 10:18 ` [ruby-dev:50921] " sawadatsuyoshi
2020-03-11  2:09 ` [ruby-dev:50922] " nobu

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 NNTP newsgroup(s).