Re: Partition List
- To: mathgroup at smc.vnet.net
- Subject: [mg8463] Re: Partition List
- From: crose at c2.telstra-mm.net.au (Colin Rose)
- Date: Tue, 2 Sep 1997 16:14:57 -0400
- Organization: Theoretical Research Institute
- Sender: owner-wri-mathgroup at wolfram.com
So many partition lists :)
While Split[m, #2 != 10 &] seems much neater than the other
functional solutions posted, it is alas also much slower.
For instance:
m = Table[Random[Integer, {1, 50}], {100000}];
Timing[p = Flatten[Position[m, 10]];
MapThread[Take[m, {#1, #2}]&, {Prepend[p, 1], Append[p-1, Length[m]]}]; ]
Out[42]= {0.39*Second, Null}
vs
Split[m,#2!=10&]; // Timing
Out[44]= {2.03333 Second,Null}
Cheers
Colin
--
Colin Rose
tr(I) - Theoretical Research Institute
______________________________________
crose at c2.telstra-mm.net.au
http://www.usyd.edu.au/su/tri/