August 19, 2024

P20 - Remove the K'th element from a list

Example:* (remove-at '(a b c d) 2)(A C D)

lisp

;;; Function that removes the element in a given ;;;
;; list. Returns the new list without the element in question ;;;

(defun remove-at (org-list pos &optional (ini 1))
    (if (eql pos ini)
        (cdr org-list)
        (cons (car org-list) (remove-at (cdr org-list) pos (+ ini 1))))
Be first to comment
Leave a reply