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