Re: Partitioning lists
- To: mathgroup at smc.vnet.net
- Subject: [mg20487] Re: Partitioning lists
- From: "Seth Chandler" <SChandler at uh.edu>
- Date: Wed, 27 Oct 1999 02:04:51 -0400
- Organization: University of Houston
- References: <7v3dfq$63d@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I am not sure this is any better, but the following also works Union[DeleteCases[ ReplaceList[{a, b, c, d, e, f}, {x___, y___} -> {{x}, {y}}], {}, Infinity]] DIAMOND Mark <noname at noname.com> wrote in message news:7v3dfq$63d at smc.vnet.net... > 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 > > > > >