Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Vector-valued functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47348] RE: [mg47321] Vector-valued functions
  • From: Jonas at iui.se
  • Date: Tue, 6 Apr 2004 06:36:32 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Use := in defining the g function:

In[1]:=
f[i_,j_,k_]:={a[i,j,k],b[i,j,k],c[i,j,k]}

In[2]:=
g[i_,j_,k_]:=f[i,j,k][[2]] 

In[3]:=
g[i,j,k]

Out[3]=
b[i,j,k]

Jonas

> -----Original Message-----
> From: me at my.co [mailto:me at my.co] 
To: mathgroup at smc.vnet.net
> Sent: den 5 april 2004 11:23
> To: mathgroup at smc.vnet.net
> Subject: [mg47348] [mg47321] Vector-valued functions
> 
> 
> 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
> 
> 


  • Prev by Date: Re: Plotting a surface side-by-side
  • Next by Date: problems with FindRoot: what worked with 4.2 does not work with 5.0
  • Previous by thread: Re: Vector-valued functions
  • Next by thread: Re: Problem with AltGr key on german keyboard