diff options
author | William Carroll <wpcarro@gmail.com> | 2020-09-01T09·17+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-09-01T09·17+0100 |
commit | fb5ec068ddd50f6bce41c7a0bad45673db787940 (patch) | |
tree | 19b4ff96983c08f451e7da5f58c95b8f6090ec84 /emacs/.emacs.d/wpc/random.el | |
parent | a638e15c0dd14a25e6f032b08de5ee1575677497 (diff) |
More Elisp linting
This should cover most of the remaining linting errors. After this, I expect fewer than ten linting errors.
Diffstat (limited to 'emacs/.emacs.d/wpc/random.el')
-rw-r--r-- | emacs/.emacs.d/wpc/random.el | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/emacs/.emacs.d/wpc/random.el b/emacs/.emacs.d/wpc/random.el index 02307a52024a..aa3c3071bb8f 100644 --- a/emacs/.emacs.d/wpc/random.el +++ b/emacs/.emacs.d/wpc/random.el @@ -33,8 +33,8 @@ ;; TODO: Make this work with sequences instead of lists. (defun random-choice (xs) "Return a random element of `XS'." - (let ((ct (list/length xs))) - (list/get + (let ((ct (list-length xs))) + (list-get (random-int ct) xs))) @@ -45,9 +45,9 @@ ;; TODO: This may not work if any of these generate numbers like 0, 1, etc. (defun random-uuid () "Return a generated UUID string." - (let ((eight (number/dec (math/triangle-of-power :base 16 :power 8))) - (four (number/dec (math/triangle-of-power :base 16 :power 4))) - (twelve (number/dec (math/triangle-of-power :base 16 :power 12)))) + (let ((eight (number-dec (math-triangle-of-power :base 16 :power 8))) + (four (number-dec (math-triangle-of-power :base 16 :power 4))) + (twelve (number-dec (math-triangle-of-power :base 16 :power 12)))) (format "%x-%x-%x-%x-%x" (random-int eight) (random-int four) @@ -57,25 +57,25 @@ (defun random-token (length) "Return a randomly generated hexadecimal string of LENGTH." - (->> (series/range 0 (number/dec length)) - (list/map (lambda (_) (format "%x" (random-int 15)))) - (list/join ""))) + (->> (series/range 0 (number-dec length)) + (list-map (lambda (_) (format "%x" (random-int 15)))) + (list-join ""))) ;; TODO: Support random-sample ;; (defun random-sample (n xs) ;; "Return a randomly sample of list XS of size N." -;; (prelude-assert (and (>= n 0) (< n (list/length xs)))) +;; (prelude-assert (and (>= n 0) (< n (list-length xs)))) ;; (cl-labels ((do-sample ;; (n xs y ys) -;; (if (= n (set/count ys)) +;; (if (= n (set-count ys)) ;; (->> ys -;; set/to-list -;; (list/map (lambda (i) -;; (list/get i xs)))) -;; (if (set/contains? y ys) -;; (do-sample n xs (random-int (list/length xs)) ys) -;; (do-sample n xs y (set/add y ys)))))) -;; (do-sample n xs (random-int (list/length xs)) (set/new)))) +;; set-to-list +;; (list-map (lambda (i) +;; (list-get i xs)))) +;; (if (set-contains? y ys) +;; (do-sample n xs (random-int (list-length xs)) ys) +;; (do-sample n xs y (set-add y ys)))))) +;; (do-sample n xs (random-int (list-length xs)) (set-new)))) (provide 'random) ;;; random.el ends here |