I am trying to do a function that removes duplicates from a list using Common Lisp on LispWorks.
So I did two functions. The first one "remove-e" removes an element from a list and a second one "remove-rep" uses the first one to return a list without duplicates.
Here is my code for the first one:
(defun remove-e (L e) (if (null L) L (if (= e (car L)) (remove-e (cdr L) e) (cons (car L) (remove-e (cdr L) e))))) It works good when given a list of numbers but when I give it letters, I get this error:
(remove-e '(a a b a d a g a h t) a) Error: The variable A is unbound. For my second function:
(defun remove-rep (l) (if (null l) l (cons (car l) (remove-rep (remove-e (cdr l) (car l)))))) This is the error message that I get when trying to test it:
CL-USER 12 : 6 > (remove-rep '(1 2 3 1 5 1 1)) Error: The variable is unbound. I saw that there are some similar questions, but couldn't find the common points of my program with these: Unbound variable in Lisp , Unbound variable in Common Lisp
=function is for comparing numbers. Useeqlif you want to be able to compare numbers or symbols, useequalif you want to be able to compare things like strings and lists.defun remove-rep (l). They're Unicode code point0x8a0.eqlandequalI'm getting the same error. How to remove the Arabic characters?asymbol to prevent it being evaluated as a variable.