diff options
Diffstat (limited to '2022')
-rw-r--r-- | 2022/lib.lisp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/2022/lib.lisp b/2022/lib.lisp index 7499e72..2441481 100644 --- a/2022/lib.lisp +++ b/2022/lib.lisp @@ -26,3 +26,17 @@ (loop for line = (read-line s nil) while line collect line))) + +(defun all (pred lst) + (if (not (cdr lst)) + (funcall pred (car lst)) + (and (funcall pred (car lst)) + (all pred (cdr lst))))) + +(defun remove-nth (n lst) + (if (or (null lst) (= n 0)) + (cdr lst) + (cons (car lst) + (remove-nth + (- n 1) + (cdr lst))))) |