1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

Add drop as alias for nthcdr

It's a common name for this function and symmetric with respect to
`take`.  It's also a lot less awkward to type and say.

* lisp/subr.el (drop): New alias.
* doc/lispref/lists.texi (List Elements): Document.  Mention the
equation tying `take` and `drop` together.
* etc/NEWS: Announce.
This commit is contained in:
Mattias Engdegård 2024-04-28 18:38:44 +02:00
parent 9b1e44c7fb
commit 8718a7c706
3 changed files with 10 additions and 0 deletions

View File

@ -317,6 +317,7 @@ For historical reasons, it takes its arguments in the opposite order.
@xref{Sequence Functions}.
@end defun
@findex drop
@defun nthcdr n list
This function returns the @var{n}th @sc{cdr} of @var{list}. In other
words, it skips past the first @var{n} links of @var{list} and returns
@ -327,6 +328,8 @@ If @var{n} is zero, @code{nthcdr} returns all of
@var{list}. If the length of @var{list} is @var{n} or less,
@code{nthcdr} returns @code{nil}.
An alias for @code{nthcdr} is @code{drop}.
@example
@group
(nthcdr 1 '(1 2 3 4))
@ -350,6 +353,9 @@ it returns the part of @var{list} that @code{nthcdr} skips.
@code{take} returns @var{list} if shorter than @var{n} elements;
it returns @code{nil} if @var{n} is zero or negative.
In general, @code{(append (take @var{n} @var{list}) (drop @var{n} @var{list}))}
will return a list equal to @var{list}.
@example
@group
(take 3 '(a b c d))

View File

@ -2013,6 +2013,9 @@ precedence over the variable when present.
Mostly used internally to do a kind of topological sort of
inheritance hierarchies.
+++
** 'drop' is now an alias for the function 'nthcdr'.
+++
** New polymorphic comparison function 'value<'.
This function returns non-nil if the first argument is less than the

View File

@ -2036,6 +2036,7 @@ instead; it will indirectly limit the specpdl stack size as well.")
;;;; Alternate names for functions - these are not being phased out.
(defalias 'drop #'nthcdr)
(defalias 'send-string #'process-send-string)
(defalias 'send-region #'process-send-region)
(defalias 'string= #'string-equal)