I tried to do the following, if I have two lists: L1 and L2, I wanted the result (R) to be a βsubtractionβ of L2 from L1.
Example:
L1 = [1,2,3] L2 = [2,3,4,5] R = [1]
I was able to accomplish this, but I cannot say what the difference is between _ and [_] .
If I do this:
diferencia([],_,[]). diferencia([X|Tail],L2,R):- member(X,L2), diferencia(Tail,L2,R). diferencia([X|Tail],L2,[X|R]):- not(member(X,L2)), diferencia(Tail,L2,R).
It works, if I do this, it gives me a lie:
diferencia([],[_],[]). diferencia([X|Tail],L2,R):- member(X,L2), diferencia(Tail,L2,R). diferencia([X|Tail],L2,[X|R]):- not(member(X,L2)), diferencia(Tail,L2,R).
I would suggest that a list containing anything [_] should work, since L2 will always be a list.