0

So, I am trying to use set-difference in Common Lisp (sbcl) and it doesn't really work on lists of structures.

For example,

* varr ;; =>
(#S(VAR :V S) #:$K520)

* pm ;; =>
(#S(VAR :V +) #S(VAR :V S) #S(VAR :V Y) #S(VAR :V X) #:$K520)

* (set-difference pm varr) ;; =>
(#S(VAR :V X) #S(VAR :V Y) #S(VAR :V S) #S(VAR :V +))

The answer should be:

(#S(VAR :V X) #S(VAR :V Y) #S(VAR :V +))

How can I fix this?

Thanks!

chez93
  • 131
  • 6

1 Answers1

0

To make it work this is how to do it:

(set-difference pm varr :test #'equalp)
chez93
  • 131
  • 6
  • 2
    This answer could be improved by adding explanations for why the original code failed and why the new code works. – ad absurdum May 07 '22 at 06:33