[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Negative nth index
From: |
Stefan Kangas |
Subject: |
Re: Negative nth index |
Date: |
Wed, 25 Dec 2024 14:18:07 +0000 |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> In CL, it errors (ditto for nthcdr with negative index). Same for (nth
>>> '(1 2 3) -1) in Clojure or (list-ref '(1 2 3) -1) in Scheme.
>> Stefan Monnier, any comments here?
>
> I don't see a strong argument in favor of making it index from the end
> rather than signal an error.
I'd make it signal an error like in CL, Clojure, and Scheme, but it
doesn't do that today, so the change would not be backwards-compatible.
So I'm not sure what to do here or how.
For reference, the current behavior is this:
(nth -1 '(1 2 3)) => 1
(nth -2 '(1 2 3)) => 1
(nth -3 '(1 2 3)) => 1
(nth most-negative-fixnum '(1 2 3)) => 1
- Re: Negative nth index, (continued)
- Re: Negative nth index, Teemu Likonen, 2024/12/24
- Re: Negative nth index, Stefan Monnier, 2024/12/24
- Re: Negative nth index, Sebastián Monía, 2024/12/24
- Re: Negative nth index, Pip Cet, 2024/12/24
- Re: Negative nth index, Mattias Engdegård, 2024/12/25
- Re: Negative nth index, Pip Cet, 2024/12/25
- Re: Negative nth index, Mattias Engdegård, 2024/12/25
- Re: Negative nth index, Pip Cet, 2024/12/25
- Re: Negative nth index, Stefan Kangas, 2024/12/25
- Re: Negative nth index, Stefan Monnier, 2024/12/25
- Re: Negative nth index,
Stefan Kangas <=
Re: Negative nth index, Andreas Schwab, 2024/12/22