Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new to Lisp and this is the first function I have written. I am trying write a lisp function (without using the remove lisp function) that takes a list from user input and an item from the list the user wishes to see removed. If the user entered item is in the list, to remove it from the list. If the item is not in the list return nil. I have an error stating (my_remove (car list) (cdr list)) should be a lambda expression I am not sure how to resolve this.

Example of proposed output:

(my_remove a' (a b c d))

(b c d)

What I have tried:

(defun my_remove (list)
	(cond ;;;Start condition
		((null list);;;check to see if the list is null
			0);;;if null then return zero 
		((eql (car list) (cdr list));;;check the list to see if there are duplicates
			((my_remove (car list) (cdr list)) (my_remove (cdr list)));;;if duplicates than skip and continue
		(t (cons (car list) (my_remove (cdr list)))))));;;the result of the list 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900