Visitor No.

Sunday 13 December 2015

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.

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)

No comments:

Post a Comment