[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] seq.el: add seq-last for symmetry with seq-first
From: |
Augusto Stoffel |
Subject: |
Re: [PATCH] seq.el: add seq-last for symmetry with seq-first |
Date: |
Wed, 15 Mar 2023 08:06:20 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.
- [PATCH] seq.el: add seq-last for symmetry with seq-first, Matúš Goljer, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Matúš Goljer, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Augusto Stoffel, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Matúš Goljer, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first,
Augusto Stoffel <=
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/15