MathGroup Archive 2008

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

Search the Archive

Re: Speeding up a list construction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93034] Re: Speeding up a list construction
  • From: carlos at colorado.edu
  • Date: Fri, 24 Oct 2008 02:31:01 -0400 (EDT)
  • References: <gdja5g$ief$1@smc.vnet.net> <gdmsdq$mh$1@smc.vnet.net>

>  Another issue I
> found is that with your example code the last item in the list a will
> not be accumulated. Is that intended or one of those index errors which
> I think are the strongest argument to use something like FoldList
> instead of Loops. To really get the same result as your code above you
> would need:

That omission is intentional. The sum of all entries is kept as a
separate variable outside the list asum.

Thanks to all who brought my attention to FoldList. I wasnt aware of
that function, but it does exist in 4.1.  The speedup is about 5:1 on my
computer.





  • Prev by Date: Re: Expressions with ellipsis (...)
  • Next by Date: Plotting an Implicit Plot with ParametricPlot
  • Previous by thread: Re: Speeding up a list construction
  • Next by thread: partial Dividers?