seppe

5 Reputation

One Badge

6 years, 278 days

MaplePrimes Activity


These are replies submitted by seppe

@Carl Love

A slap on the wrist ! Indeed evaln() do the job I asked for. But I found out why I thought the countrary :

x:=Array(1..2, 1..3);

using in my procedure the name "x" of my array and its dimensions, let say [1..2, 1..3] (through its value) I construct a list L of the names of some coefficients, let say L:=[x[1,1],x[2,3]].

I did not realized that using L, I simply get [0,0] while using evaln(L) I get "L". In no way I get the list of names [x[1,1],x[2,3]].

 

 

@Carl

Thanks Carl

NameOf:= proc(t::evaln) convert(t, string) end proc:

works perfectly. What if I need both the name and the value of t ? The only solution I found up to now is to pass the variable twice writing

NameAndValueOf:= proc(t::evaln,v) .....  end proc:

and calling it by using

NameAndValueOf(x,x)

Not very clean, is it ?

P.S. I was indeed completely wrong about Diff.

Thank you Carl,

I was not precise enough. oth your suggestions work on the command line but not inside a procedure: see the three lines below

----

> Y := Array(1 .. 2, 1 .. 3, 1 .. 5);
> NameOf := proc (t) convert(evaln(t), string) end proc;
> NameOf(Y);

give


"Array(1..2, 1..3, 1..5, [[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],[[0,0,0,0,0],\

  [0,0,0,0,0],[0,0,0,0,0]]])"
>

In fact it seems that only the value is passed to the procedure. However in functions like Diff(f(x,y),x) it is the name of the variable and not its value which is used ...

Page 1 of 1