|
[Date Index]
[Thread Index]
[Author Index]
Re: ReplaceRepeated info
- To: mathgroup at smc.vnet.net
- Subject: [mg77697] Re: ReplaceRepeated info
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 15 Jun 2007 04:31:14 -0400 (EDT)
- References: <f4r573$ber$1@smc.vnet.net>
Hi,
and
cnt = 0;
Log[d p q r] Log[a b c d] //. Log[x_ y_] :> (cnt++; Log[x] + Log[y])
will count in cnt the number of substitutions and asking for the value
of cnt will give you 6
Regards
Jens
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: Help with formatting output
Next by Date:
Re: :: notation
Previous by thread:
ReplaceRepeated info
Next by thread:
Re: ReplaceRepeated info
|