Created
October 15, 2016 11:49
-
-
Save hmenn/c03198df7cb5e5a0f59ac70af89a6534 to your computer and use it in GitHub Desktop.
remove first occurence of element from list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;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