I have a list
(SetQ L '(1 j 3 k 4 h 5 n 6 w))
I have to do a function Order that has a list with ‘n’ atoms at entry, it must check if each atom of that list is contained in list L and order them according to the order specified in list L, if the atom is not part of the list L then the result will be displayed
(Defun Order lst)
(SetQ L2'(w o 5 j 3))
I want to verify this:
(Order L2)
result should return:
(J 3 5 W)
Hints:
Earlier, you asked this question:
CLISP : Check if two elements are in order one after another in a list
This function is related to the problem because it can be used as a comparison function in a call to the standard Lisp function
sort.The Lisp function
intersectioncan produce a list which contains only those elements of one list which appear in another. This is a set operation, so it may squash duplicates; another way is to useremove-if-notwhere the test predicate is a lambda function which usesmemberto express the idea “remove all elements of this list which are not members of that other list”.