MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Computing sets of equivalences


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


  • Prev by Date: Re: ListPlot output
  • Next by Date: Re: Howto turn off using symbols to tag objects?
  • Previous by thread: Re: Computing sets of equivalences
  • Next by thread: labeling problem