diff options
| author | Nicolas Petton | 2015-02-06 15:57:54 +0100 |
|---|---|---|
| committer | Nicolas Petton | 2015-02-06 16:00:01 +0100 |
| commit | 58c098199aca5bbd782e36ff629866538cb08e32 (patch) | |
| tree | 7e29a63df14db521834add628d1f6c08ccba24d8 | |
| parent | c4a0eff0112298de0a97b63e4e22826bf2b4126c (diff) | |
| download | emacs-58c098199aca5bbd782e36ff629866538cb08e32.tar.gz emacs-58c098199aca5bbd782e36ff629866538cb08e32.zip | |
Better docstring for seq.el functions
* lisp/emacs-lisp/seq.el: Better docstring for seq.el functions
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0cd2a4d04e8..ea92da89ef2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | 2015-02-06 Nicolas Petton <nicolas@petton.fr> | 1 | 2015-02-06 Nicolas Petton <nicolas@petton.fr> |
| 2 | 2 | ||
| 3 | * emacs-lisp/seq.el (seq-mapcat, seq-partition, seq-group-by): New functions. | 3 | * emacs-lisp/seq.el (seq-mapcat, seq-partition, seq-group-by): New functions. |
| 4 | * emacs-lisp/seq.el (seq-drop-while, seq-take-while, seq-count) | ||
| 5 | (seq--drop-list, seq--take-list, seq--take-while-list): Better docstring. | ||
| 4 | 6 | ||
| 5 | 2015-02-06 Artur Malabarba <bruce.connor.am@gmail.com> | 7 | 2015-02-06 Artur Malabarba <bruce.connor.am@gmail.com> |
| 6 | 8 | ||
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index cd45989eca8..025d94e10b9 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el | |||
| @@ -92,14 +92,14 @@ returned." | |||
| 92 | (seq-subseq seq 0 (min (max n 0) (seq-length seq))))) | 92 | (seq-subseq seq 0 (min (max n 0) (seq-length seq))))) |
| 93 | 93 | ||
| 94 | (defun seq-drop-while (pred seq) | 94 | (defun seq-drop-while (pred seq) |
| 95 | "Return a sequence, from the first element for which (PRED element) is nil, of SEQ. | 95 | "Return a sequence from the first element for which (PRED element) is nil in SEQ. |
| 96 | The result is a sequence of the same type as SEQ." | 96 | The result is a sequence of the same type as SEQ." |
| 97 | (if (listp seq) | 97 | (if (listp seq) |
| 98 | (seq--drop-while-list pred seq) | 98 | (seq--drop-while-list pred seq) |
| 99 | (seq-drop seq (seq--count-successive pred seq)))) | 99 | (seq-drop seq (seq--count-successive pred seq)))) |
| 100 | 100 | ||
| 101 | (defun seq-take-while (pred seq) | 101 | (defun seq-take-while (pred seq) |
| 102 | "Return a sequence of the successive elements for which (PRED element) is non-nil in SEQ. | 102 | "Return the successive elements for which (PRED element) is non-nil in SEQ. |
| 103 | The result is a sequence of the same type as SEQ." | 103 | The result is a sequence of the same type as SEQ." |
| 104 | (if (listp seq) | 104 | (if (listp seq) |
| 105 | (seq--take-while-list pred seq) | 105 | (seq--take-while-list pred seq) |
| @@ -152,7 +152,7 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called." | |||
| 152 | t)) | 152 | t)) |
| 153 | 153 | ||
| 154 | (defun seq-count (pred seq) | 154 | (defun seq-count (pred seq) |
| 155 | "Return the number of elements for which (PRED element) returns non-nil in seq." | 155 | "Return the number of elements for which (PRED element) is non-nil in SEQ." |
| 156 | (let ((count 0)) | 156 | (let ((count 0)) |
| 157 | (seq-doseq (elt seq) | 157 | (seq-doseq (elt seq) |
| 158 | (when (funcall pred elt) | 158 | (when (funcall pred elt) |
| @@ -258,14 +258,16 @@ keys. Keys are compared using `equal'." | |||
| 258 | nil))) | 258 | nil))) |
| 259 | 259 | ||
| 260 | (defun seq--drop-list (list n) | 260 | (defun seq--drop-list (list n) |
| 261 | "Optimized version of `seq-drop' for lists." | 261 | "Return a list from LIST without its first N elements. |
| 262 | This is an optimization for lists in `seq-drop'." | ||
| 262 | (while (and list (> n 0)) | 263 | (while (and list (> n 0)) |
| 263 | (setq list (cdr list) | 264 | (setq list (cdr list) |
| 264 | n (1- n))) | 265 | n (1- n))) |
| 265 | list) | 266 | list) |
| 266 | 267 | ||
| 267 | (defun seq--take-list (list n) | 268 | (defun seq--take-list (list n) |
| 268 | "Optimized version of `seq-take' for lists." | 269 | "Return a list from LIST made of its first N elements. |
| 270 | This is an optimization for lists in `seq-take'." | ||
| 269 | (let ((result '())) | 271 | (let ((result '())) |
| 270 | (while (and list (> n 0)) | 272 | (while (and list (> n 0)) |
| 271 | (setq n (1- n)) | 273 | (setq n (1- n)) |
| @@ -273,13 +275,15 @@ keys. Keys are compared using `equal'." | |||
| 273 | (nreverse result))) | 275 | (nreverse result))) |
| 274 | 276 | ||
| 275 | (defun seq--drop-while-list (pred list) | 277 | (defun seq--drop-while-list (pred list) |
| 276 | "Optimized version of `seq-drop-while' for lists." | 278 | "Return a list from the first element for which (PRED element) is nil in LIST. |
| 279 | This is an optimization for lists in `seq-drop-while'." | ||
| 277 | (while (and list (funcall pred (car list))) | 280 | (while (and list (funcall pred (car list))) |
| 278 | (setq list (cdr list))) | 281 | (setq list (cdr list))) |
| 279 | list) | 282 | list) |
| 280 | 283 | ||
| 281 | (defun seq--take-while-list (pred list) | 284 | (defun seq--take-while-list (pred list) |
| 282 | "Optimized version of `seq-take-while' for lists." | 285 | "Return the successive elements for which (PRED element) is non-nil in LIST. |
| 286 | This is an optimization for lists in `seq-take-while'." | ||
| 283 | (let ((result '())) | 287 | (let ((result '())) |
| 284 | (while (and list (funcall pred (car list))) | 288 | (while (and list (funcall pred (car list))) |
| 285 | (push (pop list) result)) | 289 | (push (pop list) result)) |