diff options
author | Daniel Santos <dacs.git@brilhante.top> | 2023-01-12 12:20:25 +0000 |
---|---|---|
committer | Daniel Santos <dacs.git@brilhante.top> | 2023-01-12 12:33:06 +0000 |
commit | 07f426bad3819c2bd9592044352e1c4f28492e52 (patch) | |
tree | f9cad2e4203edff468f35071e010bb42a7f002e3 | |
parent | 834b16851be2d52f397dfc42c6e6b73b0188c692 (diff) | |
download | cl-math-07f426bad3819c2bd9592044352e1c4f28492e52.tar.gz |
reordening of functions in file
-rw-r--r-- | plus.lisp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/plus.lisp b/plus.lisp index 1b534b1..e833897 100644 --- a/plus.lisp +++ b/plus.lisp @@ -2,13 +2,6 @@ (defvar *number-units-at-beginning* nil) -(defun next-digit (numerals digit) - "Given a list of a numeral system and a digit, it returns the next digit." - (cond - ((eq (car (last numerals)) digit) (car numerals)) - ((not (eq (car numerals) digit)) (next-digit (cdr numerals) digit)) - (t (cadr numerals)))) - (defun may-reverse (number) "If units is placed on the end, reverse; else keep it." (if *number-units-at-beginning* @@ -23,6 +16,17 @@ "Given a list of the symbols of a number (which can have letters), it returns the symbol of this number" (intern (apply #'concatenate 'string (mapcar #'symbol-name number)))) +(defun symbol-to-number (symbol) + "Given a symbol, returns it's number." + (nth-value 0 (parse-integer (symbol-name symbol)))) + +(defun next-digit (numerals digit) + "Given a list of a numeral system and a digit, it returns the next digit." + (cond + ((eq (car (last numerals)) digit) (car numerals)) + ((not (eq (car numerals) digit)) (next-digit (cdr numerals) digit)) + (t (cadr numerals)))) + (defun next-list-number (numerals number-list) "Given a list of a numeral system and a list of a number, it returns a list of the next number." (cond @@ -69,10 +73,6 @@ "Given a list of a numeral system and 2 numbers, it returns the list of it's sum." (may-reverse (plus-args-list numerals (may-reverse (explode-to-symbol a)) (may-reverse (explode-to-symbol b))))) -(defun symbol-to-number (symbol) - "Given a symbol, returns it's number." - (nth-value 0 (parse-integer (symbol-name symbol)))) - (defun plus-decimal (&rest args) "Given decimal numbers, it returns the symbol it's sum." (nth-value 0 (implode-from-symbol (reduce (lambda (a b) (plus '(|0| |1| |2| |3| |4| |5| |6| |7| |8| |9|) a b)) args)))) |