Use of delayed assignment, :=, with a list
- To: mathgroup at smc.vnet.net
- Subject: [mg91747] Use of delayed assignment, :=, with a list
- From: phillman5 <PHILLMAN5 at gmail.com>
- Date: Sun, 7 Sep 2008 05:35:08 -0400 (EDT)
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, but if I use an
assignment operator there is no problem. I am not completely
convinced it is a mere Mathematica notation misunderstanding on my
part because a simpler 2x2 assignment:
{{q, g}, {h, k}} := {{f, w}, {r, t}}
works. (Mathematica does respond {{Null, Null}, {Null, Null}}, but g
does have a delayed assignment of w.
Is there an easier way to do a delayed assignment than each member, a,
b, c, d individually
tempmatrix := {{1, zomeasure}, {-(1/f), 1 - zomeasure/f}}
a := tempmatrix[[1]][[1]]
b := . . .