diff options
| author | LLLL Colonq <llll@colonq> | 2025-09-16 01:34:52 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-09-16 01:34:59 -0400 |
| commit | 510608fdbc43947391d82c703370814aa57a454e (patch) | |
| tree | 57c35f47ed5b2ce0c7eaa2a2553b0e39131475d5 /src/wasp-utils.el | |
| parent | fe903c535211bdbeeb703e06db0da3f7c8c19b4b (diff) | |
Update
Diffstat (limited to 'src/wasp-utils.el')
| -rw-r--r-- | src/wasp-utils.el | 13 |
1 files changed, 13 insertions, 0 deletions
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))) |
