lisp123456

Untitled

Oct 8th, 2021 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. (defun custom-proper-cons (a b)
  2. "Return a proper cons of A and B, but avoid consing NIL."
  3. (etypecase a
  4. (null (etypecase b
  5. (null nil)
  6. (atom (list b))
  7. (list b)))
  8. (atom (etypecase b
  9. (null (list a))
  10. (atom (list a b))
  11. (list (cons a b))))
  12. (list (etypecase b
  13. (null a)
  14. (atom (cons a (list b)))
  15. (list (cons a b))))))
Add Comment
Please, Sign In to add comment