[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Chopping the last element of a list
From: |
emacsq |
Subject: |
Chopping the last element of a list |
Date: |
Thu, 28 Apr 2022 09:21:23 +0000 |
If I want to do this then I can do, for example:
(prog1
(car (last mylist)) (setq mylist (nbutlast mylist)))
But here last and nbutlast walks the list twice unnecessarily.
Shouldn't emacs provide a function which does it in one step, so the list isn't
walked twice?
E.g. (choplast mylist)
which returns a cons cell of (LAST . CHOPPEDLIST)
Of course, returning two values is not very lispy, but at least it could be
more efficient.
Is there an existing function which does this in one step? If not, shouldn't
there be one built-in emacs, for efficient manipulation of the list's end?
- Chopping the last element of a list,
emacsq <=
- RE: Chopping the last element of a list, Drew Adams, 2022/04/28
- RE: Chopping the last element of a list, emacsq, 2022/04/29
- Re: Chopping the last element of a list, tomas, 2022/04/29
- RE: [External] : Re: Chopping the last element of a list, Drew Adams, 2022/04/29
- Re: [External] : Re: Chopping the last element of a list, address@hidden, 2022/04/30
- RE: [External] : Re: Chopping the last element of a list, Drew Adams, 2022/04/30
- Re: [External] : Re: Chopping the last element of a list, address@hidden, 2022/04/30