       Partial evaluation

• To: mathgroup at smc.vnet.net
• Subject: [mg21094] Partial evaluation
• From: "Kevin Jaffe" <kj0 at mailcity.com>
• Date: Sun, 12 Dec 1999 23:52:01 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```I'm sure this is a FAQ, but I haven't found the answer.

First we define:

In:= A = {{0, 0}, {0, 0}}

Out= {{0, 0}, {0, 0}}

Then the following assignment works:

In:= Part[A, 1, 1] = 1

Out= 1

In:= A

Out= {{1, 0}, {0, 0}}

But this one doesn't:

In:= Part@@{A, 1, 1} = 2

Set::write: Tag Apply in Part @@ {{{1, 0}, {0, 0}}, 1, 1} is Protected.

Out= 2

In:= A

Out= {{1, 0}, {0, 0}}

And this is even worse, of course:

In:= Evaluate[Part@@{A, 1, 1}] = 2

Set::setraw: Cannot assign to raw object 1.

Out= 2

In:= A

Out= {{1, 0}, {0, 0}}

I understand the reasons for the error messages, but I don't know how
to get around the problem.  What I need is to partially evaluate the
left-hand side of In, but I don't know how to do this.

The reason I want to do things like "Part@@{A, 1, 1} = 2" is that I'm
trying to write a module that must modify entries in an n_1 x n_2 x
... x n_k array A of arbitrary dimension k.  I can compute the desired
multi-index v = {i_1, i_2,..., i_k} for the array without knowing the
array's dimension, but I can't figure a way to assign to the
location A[[i_1, i_2, ..., i_k]].

Is there any way to do what I'm trying to do?

Thanks!

KJ

LYCOShop is now open. On your mark, get set, SHOP!!!
http://shop.lycos.com/

```

• Prev by Date: 2 coupled diff. eqns
• Next by Date: Re: Sending test to COM1 under win98 from Mathematica
• Previous by thread: Re: 2 coupled diff. eqns
• Next by thread: Re: Partial evaluation