MathGroup Archive 2007

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

Search the Archive

Re: ReplaceRepeated info

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77744] Re: ReplaceRepeated info
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 15 Jun 2007 06:21:45 -0400 (EDT)
  • References: <f4r573$ber$1@smc.vnet.net>


Hi Alessandro,

simply put a counter variable in, like:

i=0;

Log[d p q r] Log[a b c d]//.Log[x_ y_]:>(++i;Log[x]+Log[y])

i

hope this helps, Daniel





alexxx.magni at gmail.com wrote:

> Hi everybody,

> I need to use in my program ReplaceRepeated, and also to know, after

> it has been applied, how many times a replacement happened. Say, after

> this:

> 

>  Log[d p q r] Log[a b c d]//.Log[x_ y_] ->Log[x] + Log[y]

> 

> (Log[a] + Log[b] + Log[c] + Log[d]) (Log[d] + Log[p] + Log[q] +

> Log[r])

> 

> 

> ... I'd need to know that it performed 6 substitutions.

> There is a way with //. , or have I to resort to some loop around /. ,

> checking myself when no change happens anymore?

> 

> 

> Thank you!

> 

> Alessandro Magni

> 

> 




  • Prev by Date: Re: ParametricPlot3D between two curves
  • Next by Date: Re: Order of terms
  • Previous by thread: Re: ReplaceRepeated info
  • Next by thread: Mathematica 6.0 vs SELinux?