MathGroup Archive 2007

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

Search the Archive

Re: Problem with With


On Aug 26, 10:45 pm, Miguel <misv... at gmail.com> wrote:
> Let the matrix M={{Cos[alfa], -Sin[alfa], 0},{Sin[alfa], Cos[alfa],
> 0}, {0, 0, 1}}.
>
> In[]:
> With[{alfa=45=BA}, M]
>
> Out[]:
>
> Out[]: {{Cos[alfa], -Sin[alfa], 0},{Sin[alfa], Cos[alfa], 0}, {0, 0,
> 1}}
>
> Mathematica does'nt evaluate the matrix.
>
> But
>
> In[]:
> {{Cos[alfa], -Sin[alfa], 0},{Sin[alfa], Cos[alfa], 0}, {0, 0,
> 1}}/.alfa->45=BA
>
> works fine.
>
> Any idea?

With performs a replacement (not an assignment) before evaluating its
body. Use Block. Module won't work due to lexical scoping.



  • Prev by Date: Re: a mildly interesting crash
  • Next by Date: Re: subscripted local variables?
  • Previous by thread: Re: Problem with With
  • Next by thread: Re: Problem with With