Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: the rotterdam programming competition

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: the rotterdam programming competition
  • From: victor
  • Date: Mon, 16 Nov 92 21:33:42 CST

	>i have come up with an alternative program which 

	>slightly faster than splitFast

splitFast[] can be still a fastest code if we take Block[] off:

splitFast[list_,parts_] := 

     Inner[Take[list,{#1,#2}]&,
           Drop[#1,-1]+1,
           Rest[#1],
           List]&[ FoldList[Plus,0,parts] ]

My test:
parts = Table[Random[Integer,{0,5}],{50000}]; 

lis = Table[Random[Integer,{1,10}], {parts/.List->Plus}];
Timing[splitFast[lis,parts];]
{51.7333 Second, Null}
Timing[splitFast[lis,parts];]
{51.65 Second, Null}
Timing[split[lis,parts];] 

{52.9167 Second, Null}
Timing[split[lis,parts];]
{52.9833 Second, Null}

	>the first point i want to raise is that splitElegant 

	>is really not that elegant

I am agree.

Victor





  • Prev by Date: [no subject]
  • Next by Date: Plotting problems
  • Previous by thread: the rotterdam programming competition
  • Next by thread: [no subject]