From beef5560a536a8ba689090f061bb739c7112691d Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Wed, 11 Jan 2023 16:19:55 +0000 Subject: add explode-string and plus-string --- cl-math.lisp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cl-math.lisp b/cl-math.lisp index 5eae31d..5bb880d 100644 --- a/cl-math.lisp +++ b/cl-math.lisp @@ -23,6 +23,10 @@ "Given a list of a number (which can have letters), it returns the number" (intern (apply #'concatenate 'string (mapcar #'symbol-name number)))) +(defun explode-string (number) + "Given a number (which can have letters), it returns a list of the number" + (loop for letter across number collect (intern (string letter)))) + (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,6 +73,10 @@ "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 a)) (may-reverse (explode b))))) +(defun plus-string (numerals a b) + "Given a list of a numeral system and 2 strings, it returns the list of it's sum." + (may-reverse (plus-args-list numerals (may-reverse (explode-string a)) (may-reverse (explode-string b))))) + (defun symbol-to-number (symbol) "Given a symbol, returns it's number." (nth-value 0 (parse-integer (symbol-name symbol)))) -- cgit 1.4.1-2-gfad0