From f32f774eaec01d604f1a48055296716a49ebb678 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 17 Oct 2023 20:41:54 +0100 Subject: Added all and remove-nth Does what they say, all is the logical inverse to some. --- 2022/lib.lisp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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))))) -- cgit v1.2.3-13-gbd6f