8 - Define a Recursive LISP function which takes two
arguments first, an atom, second, a list, returns a list after removing first
occurrence of that atom within the list.
Implementation Code in LISP -
(defun remove( lst elt )
(cond ( (null lst) nil)
((equal ( first lst) elt ) (rest lst))
(elt ( cons( first lst)
(remove ( rest lst) elt )))))
OUTPUT-
(remove '(1 2 3 3 4 5) 3)
(1 2 3 4 5)
Implementation Code in LISP
(
(
((
(
(
OUTPUT-
(
(1 2 3 4 5)
No comments:
Post a Comment