Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'List-form arguments to pure function' topicStudent Support Forum > General > "List-form arguments to pure function"

Next Comment >Help | Reply To Topic
Author Comment/Response
Abigail
09/30/04 2:14pm

How can I convert an expression of the form

f[{x0,x1,...,xn},t]
to the form
f[x0,x1,...,xn,t] (or f[t,x0,x1,...,xn])?

In other words, I want to extract the elements of a list and use them -- not the list itself -- as arguments to a function.

The reason for this is that I'm trying to convert a list of input expressions into a pure function, and Function[] won't handle nested arguments.

---------------------------
In more detail:

I'm working with vector-valued functions (systems of ODEs) and the input to my module looks something like this:
MethodName[g_,y_,x_,<other stuff...>]
where:
-- x is the name of the independent variable
-- y is a list of names of variables dependent on whatever variable is passed as 'x'
-- g is a list of expressions involving the variables whose names are passed by 'y' and 'x'

So an example call would be
MethodName[{v,-x},{x,v},t,<other stuff>], representing a system of two ODEs:
dx/dt=v
dv/dt=-x

Inside the module, I want to create a pure function that I can use to evaluate the expressions 'g':
f=Function[{y[[1]],y[[2]],...,y[[Length[y]]],x},g]

Hence my problem. I can't just do
f=Function[{y,x},g]
(I get error Function::flpar if I try.)


URL: ,

Subject (listing for 'List-form arguments to pure function')
Author Date Posted
List-form arguments to pure function Abigail 09/30/04 2:14pm
Re: List-form arguments to pure function Henry Lamb 10/16/04 11:29pm
Re: List-form arguments to pure function Ben Kovitz 10/17/04 01:51am
Re: List-form arguments to pure function Abigail 10/18/04 05:33am
Next Comment >Help | Reply To Topic