thom@tuhold (Thom Fruehwirth) (07/27/88)
Errata: Version /*5*/ of permutations in my last posting has a typo: replace both explicit unifications Ys=[Y|Ys] by Ys=[_|_] More on permutations: Whoever has tried knows that it is quite hard to write set operations on lists which work in any direction, with any bindings. Fortunately we can save work and use permutations. Given to difference lists L1-R1 and L2-R2. If you call permute(L1,L2) (full versions, /*3*/ or /*4*/ or /*5*/) and take only the first solution, L1 and L2 will both be bound to the normal list of their union and R1 will hold the set difference of union minus L1, R2 the set difference of union minus L2. So we get union and both set differences with one call. What we did not get was the intersection of L1 and L2. We can compute it by the union minus R1 minus R2. I have to add that I did not think about efficiency. thom fruehwirth, vienna