exercise: partition a list by equivalence

Xah Lee xah at xahlee.org
Sat Feb 19 16:37:43 EST 2005


The GOTO statement from Perl has been messed up.

This block:
©    for group in interm:
©        for newcoup in fin:
©            for k in group.keys():
©                if newcoup.has_key(k):
©                    for kk in group.keys(): newcoup[kk]='x';
©                break
©            break
©        fin.append(group)
©

should be:
©    goto=False
©    for group in interm:
©        for newcoup in fin:
©            for k in group.keys():
©                if newcoup.has_key(k):
©                    newcoup.update(group);
©                    goto=True
©                    break
©            if (goto):
©                goto=False
©                break
©        else:
©            fin.append(group)

comlete code is at:
http://xahlee.org/perl-python/partition_by_equiv.html

 Xah
 xah at xahlee.org
 http://xahlee.org/PageTwo_dir/more.html




More information about the Python-list mailing list