]> code.delx.au - gnu-emacs/commitdiff
Add documentation for seq-mapcat, seq-partition and seq-group-by
authorNicolas Petton <nicolas@petton.fr>
Fri, 6 Feb 2015 15:01:12 +0000 (16:01 +0100)
committerNicolas Petton <nicolas@petton.fr>
Fri, 6 Feb 2015 15:01:12 +0000 (16:01 +0100)
* doc/lispref/sequences.texi (Sequence Functions): Add documentation
for seq-mapcat, seq-partition and seq-group-by

doc/lispref/ChangeLog
doc/lispref/sequences.texi

index e928d19c813afd06c5131921b23bf92f5cceb18c..3fe3d6fd6a0d441a7654dcae617d56e1b509a042 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-06  Nicolas Petton <nicolas@petton.fr>
+
+       * sequences.texi (Sequence Functions): Add documentation for
+       seq-mapcat, seq-partition and seq-group-by.
+
 2015-02-05  Martin Rudalics  <rudalics@gmx.at>
 
        * display.texi (Size of Displayed Text): Remove description of
index f82c49627593351993472f6634f19244b13d0933..f268c0d11e238cfe6576f7f5e3d33d33c9305b45 100644 (file)
@@ -695,9 +695,54 @@ concatenation of @var{sequences}.  @var{type} may be: @code{vector},
 @end example
 @end defun
 
+@defun seq-mapcat function sequence &optional type
+  This function returns the result of applying @code{seq-concatenate}
+to the result of applying @var{function} to each element of
+@var{sequence}.  The result is a sequence of type @var{type}, or a
+list if @var{type} is @code{nil}.
+
+@example
+@group
+(seq-mapcat #'seq-reverse '((3 2 1) (6 5 4)))
+@result{} (1 2 3 4 5 6)
+@end group
+@end example
+@end defun
+
+@defun seq-partition sequence n
+  This function returns a list of the elements of @var{sequence}
+grouped into sub-sequences of length @var{n}.  The last sequence may
+contain less elements than @var{n}.  @var{n} must be an integer.  If
+@var{n} is a negative integer or 0, nil is returned.
+
+@example
+@group
+(seq-partition '(0 1 2 3 4 5 6 7) 3)
+@result{} ((0 1 2) (3 4 5) (6 7))
+@end group
+@end example
+@end defun
+
+@defun seq-group-by function sequence
+  This function separates the elements of @var{sequence} into an alist
+whose keys are the result of applying @var{function} to each element
+of @var{sequence}.  Keys are compared using @code{equal}.
+
+@example
+@group
+(seq-group-by #'integerp '(1 2.1 3 2 3.2))
+@result{} ((t 2 3 1) (nil 3.2 2.1))
+@end group
+@group
+(seq-group-by #'car '((a 1) (b 2) (a 3) (c 4)))
+@result{} ((a (a 3) (a 1)) (b (b 2)) (c (c 4)))
+@end group
+@end example
+@end defun
+
 @defmac seq-doseq (var sequence [result]) body@dots{}
 @cindex sequence iteration
-This macro is like @code{dolist}, except that @var{sequence} can be a list,
+  This macro is like @code{dolist}, except that @var{sequence} can be a list,
 vector or string (@pxref{Iteration} for more information about the
 @code{dolist} macro).  This is primarily useful for side-effects.
 @end defmac