From 07f426bad3819c2bd9592044352e1c4f28492e52 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Thu, 12 Jan 2023 12:20:25 +0000 Subject: reordening of functions in file --- plus.lisp | 22 +++++++++++----------- 1 file 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)))) -- cgit 1.4.1-2-gfad0