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 [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BF8801F47A for ; Wed, 28 Aug 2024 14:07:46 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=onqgiK8+; 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=UtSKBByG; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1724854033; bh=NcK28aLHIEYo0tPwd5bpsuwHLofGTdVRBPUlS2bdlrg=; 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=onqgiK8+ztRqvqEUV6JkwwhBuML1i19GQbOusI9QSrnGWo4sj5/UAERI0oESY9drT ZZobMPvwz31MgxhIqpnGTWy86QakCIJfCocsBRfMPaouEWCQFotHcUwMXRZ/fZp404 rPUiul8X6C9AisDrYIHmE23MfMJ5zddnlvZUPHic= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id A179C43D59 for ; Wed, 28 Aug 2024 14:07:13 +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=UtSKBByG; dkim-atps=neutral Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 90F0C43CA4 for ; Wed, 28 Aug 2024 14:07:02 +0000 (UTC) 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=K5MJhc/iOZ0VTUdDse7P29XHOW5bm7gp07dS1dROgxY=; b=UtSKBByGi/JuSWDngUG/nHawIdxxtZlnKo8RW42W4mN2wbUs/T/MSg3BJuKslMNEyq7p qeMCL04qi/bjQPPg7gRv2htixDEmBCXTdIv9CmNaaGOwn4dOOqiahPIXtB3OX7DP1+cFgM kReZA0ai8SHTXTg6B7nISuL41KaJPpgTeQx4Q5kpm7hdxFKObURs2wTwlOu7IYSCfv6pCv hMCN7DdQvcYYZ2mmQEjqdSr5eXh4VQ33CtI7uM5kknFlAygnDvjIm0piAbNO5wLJzRawdK ZgGn3+SVZpfwGTfWaOrqb+MlRmu2ZMSymhiGKaAeBel5X0bdKKB9Hkq33RougIRg== Received: by recvd-6b556c7f5c-55mds with SMTP id recvd-6b556c7f5c-55mds-1-66CF2F05-15 2024-08-28 14:07:01.221352884 +0000 UTC m=+575491.385414892 Received: from herokuapp.com (unknown) by geopod-ismtpd-28 (SG) with ESMTP id Wx9phrcXSn2zxtdHryIPtA for ; Wed, 28 Aug 2024 14:07:01.140 +0000 (UTC) Date: Wed, 28 Aug 2024 14:07:01 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 20664 X-Redmine-Issue-Author: knu X-Redmine-Issue-Priority: Normal X-Redmine-Sender: matheusrich 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: 95614 X-SG-EID: =?us-ascii?Q?u001=2EqFs1+tfbBN=2FkBmvr1d6YKWYAJyKRqlDzPgZ9H1OmyLWHW5jct1=2FXNOw1m?= =?us-ascii?Q?bPKIHKc=2FqQ9973igTh5DDyOKJj174g8KSjHOuKw?= =?us-ascii?Q?+NckAs6maQgljmXjrKQS2=2FM4a5upp2Soa7rJwla?= =?us-ascii?Q?puYauemJcP3KeGp6BxA9IrlkbCrSEeNagiiKjGB?= =?us-ascii?Q?ngqHtKIwDXEpRb7L7X3WwY3cGZdQEvJ62S5+lUa?= =?us-ascii?Q?sFCcAwKzFsHqdKkJqCyqbt8tsMc555OnUYlP7if?= =?us-ascii?Q?mQT7p4Ik=2FoQkrRTj3i8x1iIEAQ=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: UJ3KT5S2VVDVWEAW5FPE745Y7LOJEO3B X-Message-ID-Hash: UJ3KT5S2VVDVWEAW5FPE745Y7LOJEO3B 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.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:118978] [Ruby master Feature#20664] Add `before` and `until` options to Enumerator.produce List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "matheusrich (Matheus Richard) via ruby-core" Cc: "matheusrich (Matheus Richard)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20664 has been updated by matheusrich (Matheus Richard). The kwargs proposed here could be useful: ```rb sequence.take_until(inclusive: true, &:terminator?) ``` Alternatively, we could always be inclusive and let people `pop` to remove the last element: ```rb sequence.take_until(&:terminator?).pop ``` ---------------------------------------- Feature #20664: Add `before` and `until` options to Enumerator.produce https://bugs.ruby-lang.org/issues/20664#change-109551 * Author: knu (Akinori MUSHA) * Status: Open ---------------------------------------- Enumerator.produce provides a nice way to generate an infinite sequence but is a bit awkward to define how to end a sequence. It lacks a simple and easy way to produce typical finite sequences in an intuitive syntax. This proposal attempts to solve the problem by adding these two options to the method: - `before`: when provided, it is used as a predicate to determine if an iteration should end before a generated value gets yielded. - `until`: when provided, it is used as a predicate to determine if an iteration should end until after a generated value gets yielded. Any value that responds to `to_proc` and returns a `Proc` object is accepted in these options. A typical use case for the `before` option is traversing a tree structure to iterate over the ancestors or following/preceding siblings of a node. The `until` option can be used when there is a clear definition of the "last" value to yield. ```ruby enum = Enumerator.produce(File, before: :nil?, &:superclass) enum.to_a #=> [File, IO, Object, BasicObject] enum = Enumerator.produce(3, until: :zero?, &:pred) enum_to_a #=> [3, 2, 1, 0] ``` ---Files-------------------------------- 0001-Add-before-and-until-options-to-Enumerator.produce.patch (10.7 KB) -- 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/lists/ruby-core.ml.ruby-lang.org/