aboutsummaryrefslogtreecommitdiff
path: root/src/collections.lisp
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-12-08 16:09:21 +0200
committerSyndamia <kamen@syndamia.com>2022-12-08 16:09:21 +0200
commit33be10b57d00b5fc091e2da23e4c48c02d1e2076 (patch)
tree6ae5074a59c2d940ac358e46f90ab0c93b10282d /src/collections.lisp
parentafb024163e4fee81a6a6af903abcbae2de82f2d3 (diff)
downloadsenzill-33be10b57d00b5fc091e2da23e4c48c02d1e2076.tar
senzill-33be10b57d00b5fc091e2da23e4c48c02d1e2076.tar.gz
senzill-33be10b57d00b5fc091e2da23e4c48c02d1e2076.zip
[collections] Implemented integer-to-list function
Diffstat (limited to 'src/collections.lisp')
-rw-r--r--src/collections.lisp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/collections.lisp b/src/collections.lisp
index b0da74f..84a54a2 100644
--- a/src/collections.lisp
+++ b/src/collections.lisp
@@ -13,3 +13,10 @@
(defun slice (place &key (begin 0) (end (length place)))
"Returns list of elements from begin to end indecies, inclusive"
(butlast (nthcdr begin place) (- (length place) end 1)))
+
+(defun integer-to-list (num &key (min-length 1))
+ "Returns a list where each element is a digit"
+ (loop for i = num then (floor i 10)
+ for m = (list (mod i 10)) then (push (mod i 10) m)
+ until (and (= i 0) (> (length m) min-length))
+ finally (pop m) (return m)))