From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 0B53F1F44D for ; Sat, 16 Mar 2024 03:40:45 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=SjIrrRhM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=GnkrrrPH; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id ADD89832CC; Sat, 16 Mar 2024 03:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1710560437; bh=Lwg6KmKO9GaEmLefqxO5C1LpksdEvHui2r+oiKOQsXY=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=SjIrrRhMADciMLb/U543x2ZXN/hk8qJzk8lhrR8NePJ749MhKmF1QP47FhJN9dLhD 9FpmVHueYfd7DnNM8JBweOZfu7OjI0EDjilKHIdt2xxDKy2uxFLKxpNSDtRudl2hUR MaKroLojT5liyU8piCm+mz3bhH9ZgejE1IF2FOdY= Received: from s.wrqvwxzv.outbound-mail.sendgrid.net (s.wrqvwxzv.outbound-mail.sendgrid.net [149.72.154.232]) by nue.mailmanlists.eu (Postfix) with ESMTPS id A09B8832BE for ; Sat, 16 Mar 2024 03:40:33 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=GnkrrrPH; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=PJfGFcWoPgUQRvi+EwOafmwnYwzNqIfU9YYallSlRNE=; b=GnkrrrPHcV08rCRdFxLlz0GcTZzyXbgRcbFXv4kMrIknwyngtZ5CtNr60mkceZR3ette 3MYH1FarXwq32jl32Lm7yxFFGSCyz9D3fQOxfgh15P8PRcQ7ZNI89wws8HWC7Rh4BExtXP CdyJSmGZkrDCEL+OBaZXaCpM6i9Fd19Ucix0m1/Q2Llx3i94uvUopkzcpt5zK/oZiiXuy9 yqAjxy1lG58Yu6rvZC/gpcU1ESHS3w/6AoYV/eC4/02ppD/V13aVBSjJIavevvrVysFYVn EjhK+olKFnAXPXH4V+p0IzQEZY3m3M/j7wXfLTogPMFeOjmz6ltTVjI6wbBdGIlQ== Received: by recvd-6449d6bd6c-qpd69 with SMTP id recvd-6449d6bd6c-qpd69-1-65F514AF-E 2024-03-16 03:40:31.654894711 +0000 UTC m=+1403446.418004868 Received: from herokuapp.com (unknown) by geopod-ismtpd-17 (SG) with ESMTP id VmrGQhXDT8ecVuvGZMBicw for ; Sat, 16 Mar 2024 03:40:31.624 +0000 (UTC) Date: Sat, 16 Mar 2024 03:40:31 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 19787 X-Redmine-Issue-Author: joshuay03 X-Redmine-Issue-Priority: Normal X-Redmine-Sender: joshuay03 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-Redmine-MailingListIntegration-Message-Ids: 93765 X-SG-EID: =?us-ascii?Q?u001=2ExEyErRBUn5qTpJNViHJSKnmBmECzWaN4fGvISBbo3kRgnnZS=2FnczZ+DQI?= =?us-ascii?Q?YJyNu=2FPd3qtyWh=2FbXi+i=2FD6lC4Acu4fr225cco8?= =?us-ascii?Q?OWvVvcA1TxhmK1pwmFuHI+Z24bKRfdKGISCaLnm?= =?us-ascii?Q?h6z4zVgZ9NNr3CM+OUysv3BftUyq+02NvZ6kGSx?= =?us-ascii?Q?WQhWckoEvmSNED5lv8rs90=2F=2FKDsz3Zfs8=2FxLSAw?= =?us-ascii?Q?Jm3F=2F8TgmZkVw+nTwrPamzn6QWxMWc=2FHQau5UMi?= =?us-ascii?Q?r9uCNV+NeAWttld5jZyA9g71Vg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: DXUIRVRXDV7LFGGO37OPARD3PIP6Q5DE X-Message-ID-Hash: DXUIRVRXDV7LFGGO37OPARD3PIP6Q5DE X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117199] [Ruby master Feature#19787] Add Enumerable#uniq_map, Enumerable::Lazy#uniq_map, Array#uniq_map and Array#uniq_map! List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "joshuay03 (Joshua Young) via ruby-core" Cc: "joshuay03 (Joshua Young)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #19787 has been updated by joshuay03 (Joshua Young). rubyFeedback (robert heiler) wrote in #note-6: > Ultimately you only have to convince matz. :) > > However had, matz may also request additional information and/or use case and > "usefulness" of suggestions. Once features are added it is difficult to remove > them due to backwards compatibility. Thanks, that's a good point re: backwards compatibility. > I am not really invested in the proposal here, so I will not comment much at > all. The way how I use ruby I use .map {} a lot, and .uniq sometimes, but I > don't think I really had major use cases for combining the above into one > method call. Note that I also don't use .flat_map either - I kind of prefer > to stay with one-word methods when possible. They seem to make more sense to > my brain. (I understand a rationale for e. g. library authors where efficiency > may be more important, but personally I use ruby as kind of "syntax sugar" > over C, the operating system and everyday tasks - ruby is really like the > ultimate glue language the way how I use it. But that's just a side comment, > I completely understand different people using ruby differently; just for my > own use cases I don't seem to need .uniq_map or .flat_map. By the way, I also > find it harder to remember the method names for two-word methods, e. g. > .map_uniq or .map_flat; that's also one reason I stick with oldschool method > chaining. Perhaps I am getting old ... .lazy is a bit different in that it > also defers using something at "when it is needed", along with the functional > use cases it has, which I think is different to both .flat_map and .uniq_map.) I appreciate the feedback. ---------------------------------------- Feature #19787: Add Enumerable#uniq_map, Enumerable::Lazy#uniq_map, Array#uniq_map and Array#uniq_map! https://bugs.ruby-lang.org/issues/19787#change-107288 * Author: joshuay03 (Joshua Young) * Status: Open ---------------------------------------- I would like to propose a collection of new methods, `Enumerable#uniq_map`, `Enumerable::Lazy#uniq_map`, `Array#uniq_map` and `Array#uniq_map!`. TL;DR: It's a drop in replacement for `.map { ... }.uniq`, with (hopefully) better performance. I've quite often had to map over an array and get its unique elements. It occurred to me when doing so recently that Ruby doesn't have a short form method for doing that, similar to how `.flat_map { ... }` replaces `.map { ... }.flatten` and `.filter_map { ... }` replaces `.map { ... }.compact` (with minor differences). I think these new methods could be beneficial both in terms of better performance and writing more succinct code. I've got a draft PR up with some initial benchmarks in the description: https://github.com/ruby/ruby/pull/10269. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/