Skip to content

Instantly share code, notes, and snippets.

@arkiver
Last active August 29, 2015 13:56
Show Gist options
  • Save arkiver/8877250 to your computer and use it in GitHub Desktop.
Save arkiver/8877250 to your computer and use it in GitHub Desktop.
Simple implementation(s) for finding last element from a list using Common Lisp.
(defun last-of-list (l)
"Returns last element of a list"
(nth (- (list-length l) 1) l))
@quasi
Copy link

quasi commented Feb 11, 2014

(defun last-of-list (lst)
  (unless (null lst)
    (if (null (rest lst))
        (first lst)
        (last-of-list (rest lst)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment