Using "get" inside a function



On 3/6/2011 4:29 AM, Bruce Linnell wrote:
> I'm so confused!  Is there some other option besides ' T and T ?  Why 
> doesn't it work without a ' like the example in the manual?
I don't know about the manual, but when you define a function
f(T):= blahblah(T),

the semantics of function binding mean that you could alternatively define

f(Txyz):=blahblah(Txyz).

that is, you should not expect to be able to use   get(T, ..)  any more 
than get(Txyz ..).

I can think of 3  ways around this.
Define
TensorTrace():= ....

with the understanding that TensorTrace always computes the TensorTrace 
of the matrix T.
(I don't like that..)

Another is to define
TensorTrace(T, TrankProperty) ....

and call it by
TensorTrace(T, get(T,Trank))

(I prefer that).

Perhaps another way is to define your objects like T in bundles
say TO for Tensor Object
  like this..


defstruct(TO(theMatrix,theTrank))

Then
TensorTrace(H):=
     block  ( [ m:  H at theMatrix, tk: H at theTrank] ...)
should work.

The method suggested by Leo also works because

function names like sin, cos, H,  .. are not obscured by
bindings.

e.g. f(cos):=  cos(cos)+cos  returns for f(1), the expression
cos(1)+1




RJF