diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-02-14 23:22:18 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-02-14 23:22:18 +0000 |
commit | 6a3626d961d6d1e500125af7e1c912ac4133ecd7 (patch) | |
tree | 55ca176b352f0fcffd863d7c4b03d26bbd99de07 | |
parent | 334ece1ee77c7d76a8fec046681b2f4a817685a9 (diff) | |
download | cantedraw-6a3626d961d6d1e500125af7e1c912ac4133ecd7.tar.gz cantedraw-6a3626d961d6d1e500125af7e1c912ac4133ecd7.tar.bz2 cantedraw-6a3626d961d6d1e500125af7e1c912ac4133ecd7.zip |
Implement a function to remove specific indices from a list
-rw-r--r-- | lib/functions.lisp | 6 | ||||
-rw-r--r-- | packages.lisp | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/functions.lisp b/lib/functions.lisp index 99796c9..2a7f4ab 100644 --- a/lib/functions.lisp +++ b/lib/functions.lisp @@ -54,3 +54,9 @@ where key x in A has associations {y in LST : INDICATOR(y) = x}." (fn parse-integer* (inp) (-> (string) (or integer list)) "Given string INP, attempt to parse an integer. Return NIL otherwise." (parse-integer inp :junk-allowed t)) + +(fn remove-at-indices (indices lst) (-> (list list) list) + (loop :for i :from 0 :to (1- (length lst)) + :for item :in lst + :if (not (member i indices)) + :collect item)) diff --git a/packages.lisp b/packages.lisp index 90c6dcf..e12156e 100644 --- a/packages.lisp +++ b/packages.lisp @@ -30,7 +30,8 @@ (:export :parse-integer* :range :take :split - :rev-map)) + :rev-map + :remove-at-indices)) (defpackage cantedraw.model (:use :cl :cantedraw.lib.macros :cantedraw.lib.functions) |