MathGroup Archive 2006

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

Search the Archive

Re: Iterative constants and variables definitions


Very good your attempt.
I do not have anything to suggest/comment apart from
that you could do all these using Block.

Block[{a = 1, c = 2, b = 7*a}, a*b*c]
14

Module cannot be applied here

Module[{a = 1, c = 2, b = 7*a}, a*b*c]
14*a

Use Trace to see why

Trace[With[{a=1,c=2,b=7 a},a b c]]
{With[{a=1,c=2,b=7 a},a b c],(7 a) 2,2 (7 a),2 7 a,14 a}

Trace[Block[{a=1,c=2,b=7 a},a b c]]
{Block[{a=1,c=2,b=7 a},a b c],{a=1,1},{c=2,2},{b=7 a,7 a,{a,1},7 1,7},
{{a,1},{b,7 a,{a,1},7 1,7},{c,2},7 2,14},14}

Trace[Module[{a=1,c=2,b=7 a},a b c]]
{Module[{a=1,c=2,b=7 a},a b c],{a$17=1,1},{c$17=2,2},{b$17=7 a,7 a},
{{a$17,1},{b$17,7 a},{c$17,2},(7 a) 2,2 (7 a),2 7 a,14 a},14 a}

Regards
Dimitris


  • Prev by Date: Re: How to delete a row and a column in a matrix?
  • Next by Date: Re: Inequalities
  • Previous by thread: Iterative constants and variables definitions
  • Next by thread: Re: Iterative constants and variables definitions