when I use prolog’s built-in predicate “subtract/3” : subtract(+Set, +Delete, -Result) in for example:
subtract([a,b,c,d,c,c,d,e], [c,a], X).
X = [b, d, d, e].
but I want to subtract each item in +Delete from +Set ONCE. I mean, I want
subtract([a,b,c,d,c,c,d,e], [c,a], X). to give
X = [b, d, c, c, d, e].
How can I do this?
You can build your own procedure that does that.
For example:
In every iteration you take one item from the list of items to remove, and extract one element from the input list, and then continue using the remainder of both lists.