RE: Evaluation and replacement?
- To: mathgroup at smc.vnet.net
- Subject: [mg42511] RE: [mg42489] Evaluation and replacement?
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Sat, 12 Jul 2003 05:19:11 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: AngleWyrm [mailto:no_spam_anglewyrm at hotmail.com] To: mathgroup at smc.vnet.net >Sent: Friday, July 11, 2003 8:58 AM >To: mathgroup at smc.vnet.net >Subject: [mg42511] [mg42489] Evaluation and replacement? > > >Given a quantity 20m, and a rule 10m->9m+n, how can I get the >result 18m+2n? > >( m doesn't equal n; 10m degenerates into 9m + n. 9m doesn't >degenerate into >8m+n.) >-- >-Jonathan > Not at all clear to me, what you want to attain. This perhaps??? In[95]:= Thread[(#1 -> (#1 /. i_Integer m :> Block[{q = Quotient[i, 10]}, (i - q) m + q n]) &)[ Range[7, 32] m]] Out[95]= {7 m -> 7 m, 8 m -> 8 m, 9 m -> 9 m, 10 m -> 9 m + n, 11 m -> 10 m + n, 12 m -> 11 m + n, 13 m -> 12 m + n, 14 m -> 13 m + n, 15 m -> 14 m + n, 16 m -> 15 m + n, 17 m -> 16 m + n, 18 m -> 17 m + n, 19 m -> 18 m + n, 20 m -> 18 m + 2 n, 21 m -> 19 m + 2 n, 22 m -> 20 m + 2 n, 23 m -> 21 m + 2 n, 24 m -> 22 m + 2 n, 25 m -> 23 m + 2 n, 26 m -> 24 m + 2 n, 27 m -> 25 m + 2 n, 28 m -> 26 m + 2 n, 29 m -> 27 m + 2 n, 30 m -> 27 m + 3 n, 31 m -> 28 m + 3 n, 32 m -> 29 m + 3 n} For a single application, of course, only do In[96]:= 20 m /. i_Integer m :> Block[{q = Quotient[i, 10]}, (i - q) m + q n] Out[96]= 18 m + 2 n -- Hartmut Wolf