Skip to content

Commit e7bd2f3

Browse files
Affonso-Guiknorth55
authored andcommitted
Add doc and check for positive arg in 'last' function
1 parent e5f472b commit e7bd2f3

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

doc/jlatex/jsequences.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ \subsection{リスト}
236236
\funcdesc{nthcdr}{count list}{
237237
{\em list}に{\bf cdr}を{\em count}回適用した後のリストを返す。}
238238

239-
\funcdesc{last}{list}{
240-
{\em list}の最後の要素でなく、最後のconsを返す。}
239+
\funcdesc{last}{list \&optional (n 1)}{
240+
{\em list}の最後の要素でなく、最後の{\em n}個のconsを返す。}
241241

242242
\funcdesc{butlast}{list \&optional (n 1)}
243243
{{\em list}の最後から{\em n}個の要素を削除したリストを返す。}

doc/latex/sequences.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ \subsection{Lists}
237237
\funcdesc{nthcdr}{count list}{
238238
applies {\bf cdr} {\em count} times to {\em list}.}
239239

240-
\funcdesc{last}{list}{
241-
the last cons is returned, not the last element.}
240+
\funcdesc{last}{list \&optional (n 1)}{
241+
the last {\em n} conses is returned, not the last element.}
242242

243243
\funcdesc{butlast}{list \&optional (n 1)}
244244
{ returns a list which does not contain the last {\em n} elements.}

lisp/l/common.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ if pos is bigger than the length of list, item is nconc'ed at the tail"
449449

450450
(defun rotate-list (l) (append (cdr l) (list (car l))))
451451
(defun last (x &optional (n 1))
452-
(unless (integerp n)
453-
(error "last &optional n must be integer"))
452+
(unless (and (integerp n) (>= n 0))
453+
(error "last &optional n must be a non negative integer"))
454454
(nthcdr (max (- (length x) n) 0) x))
455455
(defun copy-tree (x) (subst t t x))
456456
(defun copy-list (x) (nreverse (reverse x)))

0 commit comments

Comments
 (0)