Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2001

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

Search the Archive

Re: Converting {{a,b},{c,d}} to just {a,b},{c,d} (no enclosing parens) ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28781] Re: Converting {{a,b},{c,d}} to just {a,b},{c,d} (no enclosing parens) ?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 12 May 2001 20:18:14 -0400 (EDT)
  • References: <9di042$kuc@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The function  Level  can be useful on nested lists:

Level[{{1,2},{{3,4},{{{5,6}},{7,8}}}},{-2}]

        {{1,2},{3,4},{5,6},{7,8}}

To get a sequence:

Sequence@@%

        Sequence[{1,2},{3,4},{5,6},{7,8}]

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"aes" <siegman at stanford.edu> wrote in message
news:9di042$kuc at smc.vnet.net...
> How can I convert a list of pairs, like
>
>     {{a,b},{c,d},{e,f},. . . }}
>
> into just a sequence of pairs, i.e.
>
>    {a,b}, {c,d}, {e,f}, . . .
>
> with no outer { }'s?
>
> Reason for doing this?  Want to define a Line in the form
>
>    Line[{pt1, pt2, pt3, pt4, pt5, pt6, . . . . . . }]
>
> where some of the points, say pt1 through pt4 are individually defined;
> but then a sequence, say pt5 through pt20, are defined by a Table; then
> pt21, etc are back to individual definitions.
>
> I know -- I could break these into a sequence of Lines -- but it would
> be cleaner if there were a simple way to have one Line[ ]  command with
> all the points inside it.
>




  • Prev by Date: RE: Converting {{a,b},{c,d}} to just {a,b},{c,d} (no enclosing parens) ?
  • Next by Date: Det[]
  • Previous by thread: RE: Converting {{a,b},{c,d}} to just {a,b},{c,d} (no enclosing parens) ?
  • Next by thread: DSolve?? solution which is not a solution