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

MathGroup Archive 2007

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

Search the Archive

Re: comparing rewite rules

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78388] Re: [mg78329] comparing rewite rules
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Fri, 29 Jun 2007 05:57:27 -0400 (EDT)
  • References: <200706280831.EAA20759@smc.vnet.net>

On Jun 28, 2007, at 4:31 AM, dbsearch04 at yahoo.com wrote:

> Hello Mathematica UG:
>
> I input these 2 simple rewrite rule sets into Mathematica V5:
>
> - {yy -> 4, y -> 3}
>
> - {y -> 3, yy -> 4}
>
> I just want to compare these 2 simple rules for equality. I tried:
>
> - define each one and use % == %% (this just gives: {yy -> 4, y -> 3}
>  == {y -> 3, yy -> 4} )
> - making a symbol for each rule set and using ==, such as rul0 ==
> rul1,
>  it just echoes my input
>
> I also tried to replace the rules in an expression. If the replaced
> result evaluates to a simple expression, it is OK but, it still fails
> sometime when Mathematica reorders expressions, such as when x-1  
> becomes -1 +
> x
>
> Is it possible to determine in my code that 2 "rule lists" are the
> same?
>
> Of course, in the general case, I will have many more rules than just
> these 2 small lists (e.g. Solve[] output).
>
> Thanks in advance.


Here's one approach, use Sort to handle the ordering issues, use Same  
instead of Equal, and use Thread to map the comparisons over the  
elements giving:

And@@Thread[Sort[-{yy->4,y->3}]===Sort[-{y->3,yy->4}]]

Regards,

Ssezi


  • Prev by Date: Re: comparing rewite rules
  • Next by Date: Re: How to save/export a Manipulate[...] run to a movie file?
  • Previous by thread: comparing rewite rules
  • Next by thread: Re: comparing rewite rules