From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] seq.el: add seq-last for symmetry with seq-first Date: Wed, 15 Mar 2023 08:06:20 +0100 Message-ID: <87mt4ebij7.fsf@gmail.com> References: <871qlrmr14.fsf@gmail.com> <87fsa7cq0v.fsf@posteo.net> <87wn3jl4f8.fsf@gmail.com> <875yb3cntx.fsf@posteo.net> <87r0trb2pz.fsf@gmail.com> <87edprm1l0.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2017"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: =?utf-8?B?TWF0w7rFoQ==?= Goljer , emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 15 08:07:14 2023 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 1pcLE9-0000JB-EN for ged-emacs-devel@m.gmane-mx.org; Wed, 15 Mar 2023 08:07:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcLDR-0004el-7g; Wed, 15 Mar 2023 03:06:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcLDP-0004eF-2m for emacs-devel@gnu.org; Wed, 15 Mar 2023 03:06:27 -0400 Original-Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcLDN-00062J-IF for emacs-devel@gnu.org; Wed, 15 Mar 2023 03:06:26 -0400 Original-Received: by mail-ed1-x52a.google.com with SMTP id w9so803942edc.3 for ; Wed, 15 Mar 2023 00:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678863982; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=W4KNZWY92rErCBF/CCatJzcRN5TpccqEvk5yZEQJxwg=; b=RKDRhaTfv9X4oY4e2r3vbvVItpSY1xF6nuEMNW/GjTxHsrJZn0qkMlAs68Qh7Kr38t iJVVBUi2IdDXXcBYPwlTBpUvOrfcSeF2bVyd3OybDHdz5l6qngDrC/dDLW3scwCmnFvr 2axePK1Pu/2FD1at5YDG6quRS0Syp7EaqZaz4wEr35J0SslpH++zDd3a55bgTGDOf5Y9 z6UrTFOEp+u+s9EK3WNP1JVnP5tEYFI25kZhbSJAKDUgU81FBpNvQj26bnXfBRbea11T N/w3iVYfsGNI07sBuwnR8qDscynL8NnRF+G4cwUBYjCfk07yfjleJc/jqNKL/BM+mmBQ C6lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678863982; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=W4KNZWY92rErCBF/CCatJzcRN5TpccqEvk5yZEQJxwg=; b=FmT4fq+Dr9xPrM2JHYYr2DCSEL3YKbo2zry7eCE4j3DrXQA7S2NfpkgooJ33fc6Hsm d9+jX9cgQE69yaPGUFOA77FA/BQrkpM4f3+na5BlxFATf+pUolXL7aNI//mWBSV2WSY3 Lth7UlrK3PnOR8VXQK6CEja2T+2Cz2d4DjnFyeGdEzX5nKMtDgD8Qhz5ck7ibjzHsZ9L 096ASd1lR+gmc0uSWLOiNY8Pc+vfiMGprMeVFA8o+v7Wa86pBSB2C8O6s+clm4DJxEql HXZWzfLj/xtIRq+agqIIcTJW5GxSs5gVkApvh1FKKYLuRilsPmt5KJ7FSDFQxe4khObL 5EoA== X-Gm-Message-State: AO0yUKXAbgWWyIvEbMAOo/QKk2JWhk7xnMdjF61VfM8ntGVkD9JPVFPp /VaxyxUsY8nEvkII7Op6Ilmemo/t64o= X-Google-Smtp-Source: AK7set/ZAdsEVebaL9VDSkquhxRNbEX7ZAHyEr9X/jOVoLSqGqZgZCEDUPIm8XM58zEL6HKlzF6LVQ== X-Received: by 2002:a17:906:55b:b0:8b1:3d04:c2da with SMTP id k27-20020a170906055b00b008b13d04c2damr7555447eja.45.1678863982637; Wed, 15 Mar 2023 00:06:22 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::8ca4]) by smtp.gmail.com with ESMTPSA id jp19-20020a170906f75300b009231714b3d4sm2037232ejb.151.2023.03.15.00.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 00:06:22 -0700 (PDT) In-Reply-To: <87edprm1l0.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 14 Mar 2023 22:04:43 +0000") Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=arstoffel@gmail.com; helo=mail-ed1-x52a.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 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304476 Archived-At: On Tue, 14 Mar 2023 at 22:04, Philip Kaludercic wrote: >>> Maybe it's more useful to allow negative arguments in seq-elt? Saying >>> (seq-elt seq -1) isn't much more effort than (seq-last seq). >> >> I'm personally a bit ambiguous about negative indices. It's nice for >> those one liners when you need them, but they are quite confusing >> especially if you switch between languages and they all implement them a >> bit differently. > > The only language I am really familiar with is python, and what that > effectively does is (mod i (length n)), what do other languages do? In Python "abc"[-4] throws and error. I don't think there's any choice to be made here: If it were to support a negative index n, then (seq-elt s n) should just return the (+ (length s) n)-th element, with the usual treatment for out of bounds indices (whatever it is). > Another thing that should be kept in mind that sequences can be streams > (as provided by stream.el), and there doesn't have to be a final > element. What is the seq-length of an infinite stream? And does asking for the length of a stream consume it? If so, then seq is an imperfect abstraction for streams.