diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-11-01 20:42:23 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-11-01 20:42:23 -0700 |
commit | 5e8ae421a2198ed30022c2e8596f175799d36015 (patch) | |
tree | 7883215fd6533c1617ba4744616aa9bf48d76550 /seq-25.el | |
parent | 9b1cb53eea8a9637f7f9db5347ab306dd9bca079 (diff) |
New upstream version 2.19
Diffstat (limited to 'seq-25.el')
-rw-r--r-- | seq-25.el | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |