       Re: Table/Evaluate

• To: mathgroup at smc.vnet.net
• Subject: [mg30642] Re: [mg30627] Table/Evaluate
• From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
• Date: Sat, 1 Sep 2001 01:08:14 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```All of your examples reduce to two simple facts. If a function f has the
attribute HoldFirst or HoldAll and g does not have then f[Evaluate[a]]
will evaluate a before applying f but f[g[Evaluate[a]] will apply f
without evaluating its argument. In other words, Evaluate only has any
effect if it appears as the Head of an argument that would otherwise be
held. In your case Table has the attribute HoldAll. So

Table[Evaluate[p], {p, 4}]

evaluates p before applying Table, hence p becomes 10 etc.

Table[{Evaluate[p]}, {p, 4}]

is of course Table[List[Evaluate[p]],{p,4}] . Since Evaluate is now
hidden to Table (the head of the first argument is List) the argument of
Table is not evaluated and the evaluation proceeds as usual.

Table[Evaluate[{p}], {p, 4}]

This time again Table can see Evaluate so it evaluates its argument
first.

Table[Evaluate[{p}] // Flatten, {p, 4}]

This is just Table[Flatten[Evaluate[{p}]] , {p, 4}] so again Table can't
see Evaluate as the Head of the first argument is Flatten.

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/

On Saturday, September 1, 2001, at 08:58  AM, Bernd Brandt wrote:

> Dear group,
>
> With Table and Evaluate i found some things i did not expect.
> I would like to know if someone understands this behaviour exemplified
> below.
>
> Regards,
> Bernd
>
>
> p=10;
>
> Table[Evaluate[p], {p, 4}]
> { 10, 10, 10}
>
> Table[{Evaluate[p]}, {p, 4}]
> {{1}, {2}, {3}, {4}}
>
>
> Table[Evaluate[{p}], {p, 4}]
> {{10}, {10}, {10}, {10}}
>
> Table[Evaluate[{p}] // Flatten, {p, 4}]
> {{1}, {2}, {3}, {4}}
>
>

```

• Prev by Date: Re: integer solutions
• Next by Date: Operators
• Previous by thread: Re: integer solutions