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: <email@example.com> <firstname.lastname@example.org>
> 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.