diff options
Diffstat (limited to '2024/util.lisp')
-rw-r--r-- | 2024/util.lisp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/2024/util.lisp b/2024/util.lisp index f9b1d86..11ec230 100644 --- a/2024/util.lisp +++ b/2024/util.lisp @@ -5,7 +5,16 @@ appending `((_ ,f))) _))) -(defun zip (a b) - (loop for i in a - for j in b - collect (cons i j))) +(defun search-all (substr str &optional acc len) + (let ((x (search substr str)) + (len (or len 0))) + (if (null x) + (reverse acc) + (search-all substr (subseq str (1+ x)) + (cons (+ x len) acc) + (+ len x 1))))) + + (defun zip (a b) + (loop for i in a + for j in b + collect (cons i j))) |