       Evaluation of args in pure functions

• To: mathgroup at smc.vnet.net
• Subject: [mg16924] Evaluation of args in pure functions
• From: Andrea Sosso <sosso at dns.ien.it>
• Date: Thu, 8 Apr 1999 02:32:34 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Hello Group:

Mathematica seems to evaluate arguments in a different way, when
applying pure functions rather than using the usual function form:

Here is and example:

>>> a)  Usual form

In:=Unevaluated[ Simplify[1 + 2 x + x^2] ]
2
Out=Unevaluated[ Simplify[1 + 2 x + x ]]

>>> b)  Pure function @

In:=Unevaluated[#]& @ Simplify[1 + 2 x + x^2]
2
Out=Unevaluated[(1 + x) ]

The trace confirms evaluation order is different in these two cases:

>>> A)  Usual form

In:=Trace[ Unevaluated[ Simplify[1 + 2 x + x^2] ]
2          2
Out={Simplify[1 + 2 x + x ], (1 + x) }

>>> B)  Pure function @

In:=Unevaluated[#]& @ Simplify[1 + 2 x + x^2]

Out={{#1 & , Unevaluated[#1] & },
2          2
{Simplify[1 + 2 x + x ], (1 + x) },
2
(Unevaluated[#1] & )[(1 + x) ],
2
Unevaluated[(1 + x) ]}

Why ?
And how to control evaluation in pure functions ?

Thanks to anyone giving help.

--

Andrea Sosso

Istituto Elettrotecnico Nazionale "Galileo Ferraris"
Settore Metrologia Elettrica
10135 TORINO

Phone: +39 11 3919436
Fax: +39 11 3919436 / 346384
----------------------------
E-mail:sosso at me.ien.it
sand at cstv.to.cnr.it

```

• Prev by Date: Re: Re: binomial distribution
• Next by Date: overwrite separate notebook
• Previous by thread: Mie Scattering w/Mathematica
• Next by thread: Re: Evaluation of args in pure functions