RE: Obtaining sequences from lists of lists
- To: mathgroup at smc.vnet.net
- Subject: [mg36226] RE: [mg36168] Obtaining sequences from lists of lists
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 27 Aug 2002 02:07:38 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Bob,
Mathematica has commands to do exactly what you wish and their use is fairly
common. The first command is Apply (@@ in prefix form) and the second
command is Sequence.
If you have a list of arguments such as...
arglist = {{a, b}, c, {d, e}, 3, Report -> True};
you can insert them into a function, f, simply by applying f to the list.
f @@ arglist
f[{a, b}, c, {d, e}, 3, Report -> True]
If you want to insert them into another function, h, that also has other
arguments, then you can use Sequence and Apply.
h[firstarg, Sequence @@ arglist, Compile -> False]
h[firstarg, {a, b}, c, {d, e}, 3, Report -> True, Compile -> False]
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Bob [mailto:rdobrow at carleton.edu]
To: mathgroup at smc.vnet.net
Can anyone help me with this problem.
If I have an n-element list, (say where each element is itself a
list), such as {{a,b}, {a,b}, {a,b}}
is there a way to strip off the outermost nesting of the list to
obtain just a sequence of of these n elements, that is
{a,b},{a,b},{a,b} so that I can use this for input for some function.
I would like to do something like
Outer[SomeFunction, Table[{a,b},{N} ]] where I can enter N
dynamically.
The problem, of course, is that the output of the Table command is one
big list
and Outer is expecting a sequence of N separate lists after
SomeFunction.
Thanks for your help in advance.