From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: master d62766305a: Add `take` and `ntake` (bug#56521) Date: Mon, 18 Jul 2022 10:48:25 +0200 Message-ID: <87r12ierhi.fsf@gmail.com> References: <165807284522.13427.2673143161208860104@vcs2.savannah.gnu.org> <20220717154726.F2455C00095@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15077"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 18 10:53:36 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDMVT-0003hg-N2 for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Jul 2022 10:53:35 +0200 Original-Received: from localhost ([::1]:41516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDMVS-0006ky-6n for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Jul 2022 04:53:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDMQY-0002Nq-KT for emacs-devel@gnu.org; Mon, 18 Jul 2022 04:48:35 -0400 Original-Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:43561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDMQX-0001r7-1f for emacs-devel@gnu.org; Mon, 18 Jul 2022 04:48:30 -0400 Original-Received: by mail-wm1-x336.google.com with SMTP id j29-20020a05600c1c1d00b003a2fdafdefbso6894166wms.2 for ; Mon, 18 Jul 2022 01:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:gmane-reply-to-list:date :message-id:mime-version:content-transfer-encoding; bh=v1kCBXo0Tr2bIjLlFGB5Bdb8PkhNnXgPQKxg1bZ3WrA=; b=ZRXMtcSXv/Ac4l4ecX3TFFkhn3qMm+mszZjO+fsb4dYjgly/8uEOi2mYdUpiLTPSOz f6bOxAtIWhjwsr9QvxYCQtEAwu2xCnljXEjzbp9NtBoQPUzsrHxn0d0htFya4oylfEna rfs2RbFTdQoBDadMg6e+ka+VM1SdB92HxcTP4fmylf9OXg6PP8MtbwJuEBxT+hvYVm+j 2ytrjVpUe/SOf5Qjn6xmeyegDb/xzlZaUyU63jYtxK8ke1BjY2QkY3K7R9g/AXbeERiR fFcJ1t+LNuRm7k0o/Al7Jfa4Vb5iXOaV9ancV1uitJxHAOxcvgFMVde2m9+eu3fG3eDm XncA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :gmane-reply-to-list:date:message-id:mime-version :content-transfer-encoding; bh=v1kCBXo0Tr2bIjLlFGB5Bdb8PkhNnXgPQKxg1bZ3WrA=; b=09ahzVIwuA9S4EY4/u/yhpWxduZ+AUxAAND2U24wLhS1OYGQjZ+8NhAqmEGqZtvWix 5er4qb3/hioPc41MArC1rk9LOHKvT93NLnK+NpklhAFpCsx2TXEKihLDxpNVYgkB0+po +MUgMUUIgxJhU0zneHIldt5cvzXGSeFLzL2f2ArtZobNKyCFwIsW1BLNGP8ll2A8zcBy 1nuO3JuuuZAzzgdO/JgFNyai9tHDE/qNYOtQvl13BZ+b5Ae9GC8bQi7jqRnyoo+dUxbb NemC1c4s8Ni8Uj8lxPh6AykIo8wQTtiYt5oqQnRUpc+VjZz2d7CtUggejnv/AeQAkE+o 7cWA== X-Gm-Message-State: AJIora/IKKYnZa+ctqNvP2Bnf06EirTVuoMqqe4KBa/blFDirjsq8U+e 3hVqnCaB8O9N/tfb1bi1ulE= X-Google-Smtp-Source: AGRyM1v054OFt/wo0cntg6u9yEcn5fRjoFS6vLxhUor00cEHknvyAfhU9fnuszkrDFU+wncBGZFfYw== X-Received: by 2002:a05:600c:3549:b0:3a3:16af:d280 with SMTP id i9-20020a05600c354900b003a316afd280mr7067563wmq.142.1658134106485; Mon, 18 Jul 2022 01:48:26 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb50:6792:a1bb:2e4a:e9bc]) by smtp.gmail.com with ESMTPSA id v10-20020adfebca000000b0021d76a1b0e3sm2603637wrn.6.2022.07.18.01.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 01:48:25 -0700 (PDT) In-Reply-To: <20220717154726.F2455C00095@vcs2.savannah.gnu.org> ("Mattias =?utf-8?Q?Engdeg=C3=83=C2=A5rd=22's?= message of "Sun, 17 Jul 2022 11:47:25 -0400 (EDT)") Gmane-Reply-To-List: yes Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=rpluim@gmail.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292231 Archived-At: >>>>> On Sun, 17 Jul 2022 11:47:25 -0400 (EDT), Mattias Engdeg=C3=83=C2=A5r= d said: =20 Mattias> +@defun ntake n list Mattias> +This is a version of @code{take} that works by destructively = modifying Mattias> +the list structure of the argument. That makes it faster, bu= t the Mattias> +original value of @var{list} is lost. Mattias> +@end defun Mattias> + Mattias> @defun last list &optional n Mattias> This function returns the last link of @var{list}. The @code= {car} of Mattias> this link is the list's last element. If @var{list} is Mattias> null, Does this need the usual blurb to do (setq list-var (ntake 3 list-var)) to ensure `list-var' is updated? Mattias> +DEFUN ("take", Ftake, Stake, 2, 2, 0, Mattias> + doc: /* Return the first N elements of LIST. Mattias> +If N is zero or negative, return nil. Mattias> +If LIST is no more than N elements long, return it (or a copy= ). */) Mattias> + (Lisp_Object n, Lisp_Object list) I think this would be clearer as "If N is >=3D the length of LIST, return LIST (or a copy)." since we=CA=BCre talking about the effect of various values of N. Mattias> + Mattias> +DEFUN ("ntake", Fntake, Sntake, 2, 2, 0, Mattias> + doc: /* Modify LIST to keep only the first N elements. Mattias> +If N is zero or negative, return nil. Mattias> +If LIST is no more than N elements long, return it. */) And similarly here. Robert --=20