Added all and remove-nth

Does what they say, all is the logical inverse to some.
This commit is contained in:
2023-10-17 20:41:54 +01:00
parent db2ef41d19
commit f32f774eae

View File

@@ -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)))))