Re: Computing sets of equivalences
- To: mathgroup at smc.vnet.net
- Subject: [mg46614] Re: Computing sets of equivalences
- From: "Simons, F.H." <F.H.Simons at tue.nl>
- Date: Wed, 25 Feb 2004 13:07:07 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Here is another solution of the problem. It is based on constructing a function that is constant on each equivalence class and has different values on different classes.
equivalences[lst_List] := Block[{f},
Scan[(f[#[[1]]]=f[#[[2]]]=Unique[x])&,lst];
Scan[(Evaluate[f[#[[1]]]]=f[#[[2]]])& , lst];
Reap[Sow[#, f[#]]& /@ Union@@lst][[2]]]
Only for large intial sets of initial equivalences Carl Woll's solution seems to be slightly faster.
Regards,
Fred Simons
Eindhoven University of Technology