diff options
author | Daniel Santos <dacs.git@brilhante.top> | 2023-01-11 16:19:55 +0000 |
---|---|---|
committer | Daniel Santos <dacs.git@brilhante.top> | 2023-01-11 16:19:55 +0000 |
commit | beef5560a536a8ba689090f061bb739c7112691d (patch) | |
tree | 9e196747cca79f1e85c30fb07fa397d7ce3b7f9c | |
parent | 24730b9d607945477a38f53185198d98d41d2ec4 (diff) | |
download | cl-math-beef5560a536a8ba689090f061bb739c7112691d.tar.gz |
add explode-string and plus-string
-rw-r--r-- | cl-math.lisp | 8 |
1 files changed, 8 insertions, 0 deletions
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)))) |