Skip to content

Instantly share code, notes, and snippets.

@hmenn
Created October 15, 2016 11:49
Show Gist options
  • Select an option

  • Save hmenn/c03198df7cb5e5a0f59ac70af89a6534 to your computer and use it in GitHub Desktop.

Select an option

Save hmenn/c03198df7cb5e5a0f59ac70af89a6534 to your computer and use it in GitHub Desktop.
remove first occurence of element from list
;item -> item to remove, can be atom or list
;l -> list to remove from
(defun REMOVE-FIRST (item l)
(cond
((endp l) nil) ; end of list
((equal item (first l)) (rest l)) ; if find, return rest
(t (cons (first l) (REMOVE-FIRST item (rest l)))) ; cons head item and list
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment