ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:99418] [Ruby master Feature#17097] `map_min`, `map_max`
@ 2020-07-31 12:33 sawadatsuyoshi
  2020-07-31 12:37 ` [ruby-core:99419] " nobu
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sawadatsuyoshi @ 2020-07-31 12:33 UTC (permalink / raw)
  To: ruby-core

Issue #17097 has been reported by sawa (Tsuyoshi Sawada).

----------------------------------------
Feature #17097: `map_min`, `map_max`
https://bugs.ruby-lang.org/issues/17097

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
----------------------------------------
`min`, `min_by`, `max`, `max_by` return the element that leads to the minimum or the maximum value, but I think it is as, or even more, frequent that we are interested in the minimum or the maximum value itself rather than the element. For example, to get the length of the longest string in an array, we do:

```ruby
%w[aa b cccc dd].map(&:length).max # => 4
```

I propose to have methods that return the minimum or the maximum value. Temporarily calling them `map_min`, `map_max`, they should work like this:

```ruby
%w[aa b cccc dd].map_max(&:length) # => 4
```

`map_min`, `map_max` are implementation-centered names, so perhaps better names should replace them, just like `yield_self` was replaced by `then`.



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

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

end of thread, other threads:[~2022-12-23 17:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 12:33 [ruby-core:99418] [Ruby master Feature#17097] `map_min`, `map_max` sawadatsuyoshi
2020-07-31 12:37 ` [ruby-core:99419] " nobu
2020-07-31 13:51 ` [ruby-core:99420] " grzegorz.jakubiak
2020-07-31 18:03 ` [ruby-core:99421] " eregontp
2020-07-31 18:06 ` [ruby-core:99422] " eregontp
2020-08-01  0:56 ` [ruby-core:99425] " marcandre-ruby-core
2020-08-01  3:53 ` [ruby-core:99428] " sawadatsuyoshi
2021-01-13  1:24 ` [ruby-core:102041] " universato
2022-12-23  2:14 ` [ruby-core:111387] " jnchito (Junichi Ito) via ruby-core
2022-12-23  4:30 ` [ruby-core:111390] " baweaver (Brandon Weaver) via ruby-core
2022-12-23 17:19 ` [ruby-core:111406] " Eregon (Benoit Daloze) via ruby-core

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).