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/number.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/number.el')
-rw-r--r-- | emacs/.emacs.d/wpc/number.el | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/emacs/.emacs.d/wpc/number.el b/emacs/.emacs.d/wpc/number.el index e8e1be58db0a..9d576797f1c9 100644 --- a/emacs/.emacs.d/wpc/number.el +++ b/emacs/.emacs.d/wpc/number.el @@ -40,40 +40,40 @@ ;; Library ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defconst number/test? t +(defconst number-test? t "When t, run the test suite defined herein.") ;; TODO: What about int.el? ;; TODO: How do we handle a number typeclass? -(defun number/positive? (x) +(defun number-positive? (x) "Return t if `X' is a positive number." (> x 0)) -(defun number/negative? (x) +(defun number-negative? (x) "Return t if `X' is a positive number." (< x 0)) ;; TODO: Don't rely on this. Need to have 10.0 and 10 behave similarly. -(defun number/float? (x) +(defun number-float? (x) "Return t if `X' is a floating point number." (floatp x)) -(defun number/natural? (x) +(defun number-natural? (x) "Return t if `X' is a natural number." - (and (number/positive? x) - (not (number/float? x)))) + (and (number-positive? x) + (not (number-float? x)))) -(defun number/whole? (x) +(defun number-whole? (x) "Return t if `X' is a whole number." (or (= 0 x) - (number/natural? x))) + (number-natural? x))) -(defun number/integer? (x) +(defun number-integer? (x) "Return t if `X' is an integer." - (or (number/whole? x) - (number/natural? (- x)))) + (or (number-whole? x) + (number-natural? (- x)))) ;; TODO: How defensive should these guards be? Should we assert that the inputs ;; are integers before checking evenness or oddness? @@ -83,28 +83,28 @@ ;; TODO: How should rational numbers be handled? Lisp is supposedly famous for ;; its handling of rational numbers. ;; TODO: `calc-mode' supports rational numbers as "1:2" meaning "1/2" -;; (defun number/rational? (x)) +;; (defun number-rational? (x)) ;; TODO: Can or should I support real numbers? -;; (defun number/real? (x)) +;; (defun number-real? (x)) -(defun number/even? (x) +(defun number-even? (x) "Return t if `X' is an even number." (or (= 0 x) (= 0 (mod x 2)))) -(defun number/odd? (x) +(defun number-odd? (x) "Return t if `X' is an odd number." - (not (number/even? x))) + (not (number-even? x))) -(defun number/dec (x) +(defun number-dec (x) "Subtract one from `X'. While this function is undeniably trivial, I have unintentionally done (- 1 x) when in fact I meant to do (- x 1) that I figure it's better for this function to exist, and for me to train myself to reach for it and its inc counterpart." (- x 1)) -(defun number/inc (x) +(defun number-inc (x) "Add one to `X'." (+ x 1)) @@ -112,46 +112,46 @@ While this function is undeniably trivial, I have unintentionally done (- 1 x) ;; too vague? ;; TODO: Resolve the circular dependency that this introduces with series.el, ;; and then re-enable this function and its tests below. -;; (defun number/factorial (x) +;; (defun number-factorial (x) ;; "Return factorial of `X'." ;; (cond -;; ((number/negative? x) (error "Will not take factorial of negative numbers")) +;; ((number-negative? x) (error "Will not take factorial of negative numbers")) ;; ((= 0 x) 1) ;; ;; NOTE: Using `series/range' introduces a circular dependency because: ;; ;; series -> number -> series. Conceptually, however, this should be ;; ;; perfectly acceptable. ;; (t (->> (series/range 1 x) -;; (list/reduce 1 #'*))))) +;; (list-reduce 1 #'*))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Tests ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(when number/test? +(when number-test? (prelude-assert - (number/positive? 10)) + (number-positive? 10)) (prelude-assert - (number/natural? 10)) + (number-natural? 10)) (prelude-assert - (number/whole? 10)) + (number-whole? 10)) (prelude-assert - (number/whole? 0)) + (number-whole? 0)) (prelude-assert - (number/integer? 10)) + (number-integer? 10)) ;; (prelude-assert - ;; (= 120 (number/factorial 5))) + ;; (= 120 (number-factorial 5))) (prelude-assert - (number/even? 6)) + (number-even? 6)) (prelude-refute - (number/odd? 6)) + (number-odd? 6)) (prelude-refute - (number/positive? -10)) + (number-positive? -10)) (prelude-refute - (number/natural? 10.0)) + (number-natural? 10.0)) (prelude-refute - (number/natural? -10)) + (number-natural? -10)) (prelude-refute - (number/natural? -10.0))) + (number-natural? -10.0))) (provide 'number) ;;; number.el ends here |