MathGroup Archive 1999

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

Search the Archive

Partitioning lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20439] Partitioning lists
  • From: "DIAMOND Mark" <noname at noname.com>
  • Date: Tue, 26 Oct 1999 00:33:17 -0400
  • Organization: The University of Western Australia
  • Sender: owner-wri-mathgroup at wolfram.com

I would like a function f to split a list as follows

a={1,2,3,4,5,6}
f[a] =
  {
    {{1},{2,3,4,5,6}},
    {{1,2},{3,4,5,6}},
    {{1,2,3},{4,5,6}},
    {{1,2,3,4},{5,6}},
    {{1,2,3,4,5},{6}}
  }

I can do this as

      Table[{Take[a, i], Drop[a, i]}, {i, 1, Length[a] - 1}]

but it *looks* as though it is very inefficient. Is it?
It also looks as though there should be a way of using Partition simply to
chop a list between positions i and i+1, but
I cannot see how to do it. Any suggestions?


mark diamond
no spam email: markd at psy dot uwa dot edu dot au






  • Prev by Date: How to select all cells ABOVE a given cell?
  • Next by Date: rotation matrix to Yaw-Pitch-Roll angles
  • Previous by thread: How to select all cells ABOVE a given cell?
  • Next by thread: Re: Partitioning lists