From 510608fdbc43947391d82c703370814aa57a454e Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 16 Sep 2025 01:34:52 -0400 Subject: Update --- src/wasp-utils.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/wasp-utils.el') diff --git a/src/wasp-utils.el b/src/wasp-utils.el index 894c62f3..7b3c02b4 100644 --- a/src/wasp-utils.el +++ b/src/wasp-utils.el @@ -15,6 +15,11 @@ :type '(string) :group 'wasp) +(defun w/safe-elt (seq idx) + "Return the IDXth element of SEQ." + (when (< idx (seq-length seq)) + (seq-elt seq idx))) + (defun w/read-sexp (s) "Read string S into a Lisp form. Return nil on error." @@ -67,6 +72,14 @@ BODY is passed directly to `cl-defstruct'." (let ((elt (seq-elt s (random (seq-length s))))) (cons elt (w/shuffle (remove elt s)))))) +(defun w/random-probability () + "Return a random float between 0.0 and 1.0." + (/ (float (random most-positive-fixnum)) most-positive-fixnum)) + +(defun w/random-color () + "Return a random color string." + (format "#%02x%02x%02x" (random 256) (random 256) (random 256))) + (defun w/list-to-pair (xs) "Turn the first two elements of XS into a pair." (cons (car xs) (cadr xs))) -- cgit v1.2.3