Grouping pairs - suggested tools
ian.g.kelly at gmail.com
Tue Sep 21 08:49:48 CEST 2010
On Tue, Sep 21, 2010 at 12:19 AM, Alf P. Steinbach /Usenet <
alf.p.steinbach+usenet at gmail.com <alf.p.steinbach%2Busenet at gmail.com>>wrote:
> Uhm, thinking about it (it must have been my unconscious mind doing the
> work, it just popped into my head), if you first sort each individual
> equivalence relation so that you never have e.g. C=A but only A=C and so on,
> and then sort the list of equivalences, then it should reduce to walking the
> list and just starting a new set whenever a symbol is encountered that isn't
> yet in a set.
This won't work for all inputs. Consider the input: [('a', 'd'), ('b',
'c'), ('c', 'd')]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list