Re: Use of delayed assignment, :=, with a list
- To: mathgroup at smc.vnet.net
- Subject: [mg91781] Re: Use of delayed assignment, :=, with a list
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 7 Sep 2008 22:53:46 -0400 (EDT)
On 9/7/08 at 5:35 AM, PHILLMAN5 at gmail.com (phillman5) wrote:
>I use simple 2x2 matrixes for each item in a optical train to get
>the over all 2x2 matrix. The four elements are a, b, c, d, and I can
>assign them easily in one step.
>{{a, b},{c, d}} = any 2x2 matrix
>however some times the rhs has variables, so I'd like to use an
>delayed assignment
>{{a, b},{c, d}} := any 2x2 matrix
>this does not work, Mathematica says the two lists are not the same
>shape. In particular:
>{{a, b},{c, d}} := {{1, zomeasure}, {-(1/f), 1 - zomeasure/f}}
>where f and zomeasure are variables (maybe not even defined yet).
>Mathematica says the lists are not the same shape,
Are you sure you don't have something previously defined? I just
pasted the code above you say doesn't work into a fresh session
and it seems to work fine. That is:
In[1]:= {{a, b}, {c, d}} := {{1, zomeasure}, {-(1/f),
1 - zomeasure/f}}
Out[1]= ({Null,Null},{Null,Null}}
In[2]:= a
Out[2]= 1
In[3]:= b
Out[3]= zomeasure
In[4]:= c
Out[4]= -(1/f)
In[5]:= d
Out[5]= 1-zomeasure/f