Re: Vector-valued functions
- To: mathgroup at smc.vnet.net
- Subject: [mg47360] Re: Vector-valued functions
- From: drbob at bigfoot.com (Bobby R. Treat)
- Date: Tue, 6 Apr 2004 06:37:05 -0400 (EDT)
- References: <c4rdik$mcf$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
g[i_,j_,k_]:=f[i,j,k][[2]]
Bobby
me at my.co (me) wrote in message news:<c4rdik$mcf$1 at smc.vnet.net>...
> Hi, Experts !
> I often encounter the following situation:
> I have a function that creates a list (=vector) as output.
> For example:
> f[i_,j_,k_]:={a[i,j,k],b[i,j,k],c[i,j,k]}
> I have to use, for example, the second part of the vector
> in a subsequent expression. When I try that as, for example,
> g[i_,j_,k_]=f[i,j,k][[2]]
> Mathematica gives the error message 'Part n does not exist'
> because f[i,j,k] is indeed not yet evaluated.
> What is the best way to I make [[...]] behave like [...] so that it stays
> unevaluated unless it can be evaluated ?
> I can think of three ways:
> - Use functional arguments [...] instead of lists [[...]] alltogether.
> - Rename Part[...] into something else so that Mathematica does not complain.
> - Make frequent use of Hold[...].
> All three ways are a bit ugly, I feel. Which (other) method is preferred ?
> I could imagine that this is a rather common question but I found no
> discussion about it.
>
> Thank you !
> Michael