(in-package :senzill.collections) (defmacro push-back (item place) "Item is appended to the (right) end of the place (list)" `(setf ,place (append ,place (list ,item)))) (defmacro pop-back (place) "Removes destructively last element and returns it" `(let ((val (car (last ,place)))) (setq ,place (nbutlast ,place)) val)) (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)))