August 19, 2024

P01 - Find the last box of a list

- Example:* (my-last '(a b c d))(D)

lisp

(defun my_last (list)
  (if (null list)
      nil
    (if (null (rest list))
        list                     ; tests if the list has only one element
       (my_last (rest list))      ; recurse on the rest of the list
     )
   )
 )
Be first to comment
Leave a reply