Article View: comp.lang.prolog
Article #3522more on permutations + errata
From: Thom Fruehwirth
Date: Wed, 27 Jul 1988 15:49
Date: Wed, 27 Jul 1988 15:49
20 lines
1182 bytes
1182 bytes
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
Technical Details
Message-ID:
<1075@tuhold>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!tuvie!tuhold!thomShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!tuvie!tuhold!thom From: thom@tuhold (Thom Fruehwirth) Newsgroups: comp.lang.prolog Subject: more on permutations + errata Message-ID: <1075@tuhold> Date: 27 Jul 88 15:49:18 GMT Organization: Institut f. Angewandte Informatik, TU Vienna Lines: 20