I was trying to accomplish the following, if I have two lists, L1 and L2, I wanted that the result (R) to be the "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 can't tell what is the difference 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 false:
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 assume a list containing anything [_]
should work since L2 will always be a list.