From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id E2F9C1F5AE for ; Fri, 31 Jul 2020 12:33:50 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BD4A6120B5C; Fri, 31 Jul 2020 21:33:19 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id AD559120B57 for ; Fri, 31 Jul 2020 21:33:17 +0900 (JST) Received: by filterdrecv-p3iad2-d8cc6d457-4rql4 with SMTP id filterdrecv-p3iad2-d8cc6d457-4rql4-20-5F240FA3-6C 2020-07-31 12:33:39.538629387 +0000 UTC m=+152724.483347639 Received: from herokuapp.com (unknown) by ismtpd0007p1iad2.sendgrid.net (SG) with ESMTP id rRL6y08HQDOO6bxhNNXU9Q for ; Fri, 31 Jul 2020 12:33:39.521 +0000 (UTC) Date: Fri, 31 Jul 2020 12:33:39 +0000 (UTC) From: sawadatsuyoshi@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75246 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17097 X-Redmine-Issue-Author: sawa X-Redmine-Sender: sawa X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?jFXA8Rt481sXUUIO9tYW1AJlMOZdNdlSw=2F5TfLCefGs=2FYvjhp9=2F1EyK7R615ds?= =?us-ascii?Q?1stXmjR7SfR+PjA5dSt2x3=2FpDc0IrnWbRIxNQN+?= =?us-ascii?Q?MfZjnM7D+GHAO07+sLjNDfPGMmFRqDEnRLePdde?= =?us-ascii?Q?3PZntj5yHfO25u=2F=2FBZklrXJjm2H9kJ3+6U57E7Q?= =?us-ascii?Q?Ee57pdVVl0ZU2mnLjvkEsOFhipAPCRJZ3xzSVmy?= =?us-ascii?Q?Tzv7N0Hm5dyH5stxg=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99418 Subject: [ruby-core:99418] [Ruby master Feature#17097] `map_min`, `map_max` X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/