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: ReplaceRepeated info

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77719] Re: [mg77673] ReplaceRepeated info
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Fri, 15 Jun 2007 04:42:37 -0400 (EDT)
  • References: <10606890.1181818343818.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

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

Log[x_ y_] :> (counter++; Log[x] + Log[y])

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

6

Bobby

On Thu, 14 Jun 2007 05:19:30 -0500, alexxx.magni at gmail.com  
<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
>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: Mathematica 6.0 not running in Fedora 7?
  • Next by Date: Eigenvalues
  • Previous by thread: Re: ReplaceRepeated info
  • Next by thread: Re: ReplaceRepeated info