Bug fix: Problems with unapply

The function unapply , which constructs a procedure from an expression, has two major shortcomings, listed below. To correct them, I have written the alternative procedure vnapply .

> f:=unapply(vector([1,x,x^2]), x);

f := proc (x) options operator, arrow; array(1 .. 3...

> f(t);

vector([1, x, x^2])

> F:= unapply(Vector([1,x,x^2]), x);

F := proc (x) options operator, arrow; Vector[colum...
F := proc (x) options operator, arrow; Vector[colum...

> F(t);

_rtable[19403032]

Here it is with vnapply :

> f:= vnapply(vector([1,x,x^2]), x);

f := proc (x) options operator, arrow; array(1 .. 3...

> f(t);

vector([1, t, t^2])

> F:= vnapply(Vector([1,x,x^2]),x);

F := proc (x) options operator, arrow; Vector([1, x...
F := proc (x) options operator, arrow; Vector([1, x...

> F(t);

_rtable[7541504]

> unapply(diff(g(x),x), x);
unapply(diff(g(x,y),y),y);

D(g)

proc (y) options operator, arrow; D[2](g)(x,y) end ...

Unfortunately, unapply fails to do this in slightly more complicated circumstances.

> unapply(2*diff(g(x),x), x);
unapply(diff(g(x,y),x)+diff(g(x,y),y),(x,y));

proc (x) options operator, arrow; 2*diff(g(x),x) en...

proc (x, y) options operator, arrow; diff(g(x,y),x)...

Here they are with vnapply :

> vnapply(2*diff(g(x),x), x);
vnapply(diff(g(x,y),x)+diff(g(x,y),y),(x,y));

proc (x) options operator, arrow; 2*D(g)(x) end pro...

proc (x, y) options operator, arrow; D[1](g)(x,y)+D...

See also: array , D , diff , evalhf , table , unapply , vnapply

Maple Advisor Database, R. Israel 2000