Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

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


  • 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