       Re: Lists without outer braces

• To: mathgroup at smc.vnet.net
• Subject: [mg8400] Re: [mg8306] Lists without outer braces
• From: Daniel Lichtblau <danl>
• Date: Tue, 26 Aug 1997 20:41:40 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```K. Nikolaj Berntsen wrote:
>
> Hi Group,
>
> Is there any way to produce a list without the outer braces?
> For example how do you produce:
>
> {x1,1},{x2,1},{x3,1}
> from
> {{x1,1},{x2,1},{x3,1}}
>
> My real problem is to save a lot of typing in the following expression
> where 'n' either is a fixed number or a variable one.
>
> FindMinimum[
>         Sum[x[i],{i,1,n}]
>         ,{x,1} , {x,1} ,  ... , {x[n],1}
> ]
>
> (this problem is not well posed, but it illustrates what I need).
>
> Happy Computing,
> Nikolaj
> --
> ....

You can apply Sequence to the list in order to splice in the elements as
separate arguments to some function. For example:

In:= startlist = {{x1, 1}, {x2, 1}, {x3, 1}};

In:= eqns = {x1^2-2*x1*x2-x2*x3+3==0, x1*x3==x2, x1+x2-x3^2==3};

In:= FindRoot[eqns, Evaluate[Apply[Sequence, startlist]]]
Out= {x1 -> 2.04235, x2 -> 1.48963, x3 -> 0.729371}

The Evalaute wrapper is needed because FindRoot has the attribute
HoldAll.

Daniel Lichtblau
Wolfram Research
danl at wolfram.com

```

• Prev by Date: RE: Matrix Diagonalisation
• Next by Date: Mma Package Style Question
• Previous by thread: Re: Lists without outer braces
• Next by thread: NonlinearFit and NonlinearRegression