summaryrefslogtreecommitdiff
path: root/seq-25.el
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2016-11-01 20:42:23 -0700
committerSean Whitton <spwhitton@spwhitton.name>2016-11-01 20:42:23 -0700
commit5e8ae421a2198ed30022c2e8596f175799d36015 (patch)
tree7883215fd6533c1617ba4744616aa9bf48d76550 /seq-25.el
parent9b1cb53eea8a9637f7f9db5347ab306dd9bca079 (diff)
New upstream version 2.19
Diffstat (limited to 'seq-25.el')
-rw-r--r--seq-25.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/seq-25.el b/seq-25.el
index b2f5c98..c2268dd 100644
--- a/seq-25.el
+++ b/seq-25.el
@@ -91,7 +91,7 @@ given, and the match does not fail."
ARGS can also include the `&rest' marker followed by a variable
name to be bound to the rest of SEQUENCE."
- (declare (indent 2) (debug t))
+ (declare (indent 2) (debug (sexp form body)))
`(pcase-let ((,(seq--make-pcase-patterns args) ,sequence))
,@body))
@@ -131,7 +131,7 @@ Return SEQUENCE."
(cl-defgeneric seq-subseq (sequence start &optional end)
"Return the sequence of elements of SEQUENCE from START to END.
-END is inclusive.
+END is exclusive.
If END is omitted, it defaults to the length of the sequence. If
START or END is negative, it counts from the end. Signal an
@@ -494,5 +494,12 @@ SEQUENCE must be a sequence of numbers or markers."
If no element is found, return nil."
(ignore-errors (seq-elt sequence n))))
+(cl-defgeneric seq-random-elt (sequence)
+ "Return a random element from SEQUENCE.
+Signal an error if SEQUENCE is empty."
+ (if (seq-empty-p sequence)
+ (error "Sequence cannot be empty")
+ (seq-elt sequence (random (seq-length sequence)))))
+
(provide 'seq-25)
;;; seq-25.el ends here