I want to write a function that takes as parameters two lists and checks if every element in the first one is included in the second ( the order of the elements doesn't matter). The function will also be checking if the two list have the same length (the two list can't have duplicate elements) because if not then the function will return nill/false.
For example: (A B C D E F) and (B E A F D C) have the same elements (nil) and (nil) have the same elements
(A B C D E F) and (A B C D E F G) don't have the same elements
The problem is that I know only some basic commands and I can use just those ones. These are almost all the commands that I know:
CAR, CDR, LENGTH, NULL, MEMBER, NOT, AND, OR, NOT, MAPCAR, APPLY, DO, SETQ, LET
I wrote the following function up until now, but I don't know how to check for duplicate members and it doesn't work properly for all the lists that I want to check:
(defun same-elem-p (lst1 lst2)
(cond ((not (null lst1))
(cond ((member (car lst1) lst2)
(same-elem-p (cdr lst1) lst2))
(t nil)))
(t t)))
I hope I explained the problem well enough.