Question: It's a LISP Programming problem please help me! I need to make remove-2nd function! The result must be like this!! (remove-2nd a (b a n

It's a LISP Programming problem please help me!

I need to make remove-2nd function!

The result must be like this!!

(remove-2nd a (b a n a n a)) => (b a n n a)

(remove-2nd a (b (a n) a n a) => (b (a n) a n)

(remove-2nd (1 2) (1 2 (1 2) 3)) => (1 2 (1 2) 3)

i made the code like this...

(defun remove2nd (x y) (if (null y) '() (if(eq x (car y)) (setq mycount (+ mycount 1)) (if(eq mycount 2) (remove2nd x (cdr y)) (cons(car y) (remove2nd x (cdr y)))) (cons(car y) (remove2nd x (cdr y))))))

But it doesn't work.... help me

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!