Vegetarianboy30

out of ideas in lisp

Jan 20th, 2021
1,092
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.25 KB | None | 0 0
  1. (defun list-intersection (L1 L2)
  2.   "Return a list containing elements belonging to both L1 and L2."
  3.   (cond
  4.    ((null L1) nil)
  5.    ((member (first L1) L2)
  6.     (cons (first L1) (list-intersection (rest L1) L2)))
  7.    (t (list-intersection (rest L1) L2))))
Add Comment
Please, Sign In to add comment