Re: List concatenation speed
- To: mathgroup at smc.vnet.net
- Subject: [mg87589] Re: List concatenation speed
- From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
- Date: Mon, 14 Apr 2008 05:41:01 -0400 (EDT)
- References: <4801C556.1060408@gmail.com>
On Sun, Apr 13, 2008 at 6:32 PM, Carlos Felippa
<Carlos.Felippa at colorado.edu> wrote:
> Hi,
>
> The problem with your solution is that the p's are not
> available synchronously. They are Graphics objects, some quite
> complicated, computed sequientally and catenated to form the Show[]
> list. If I knew their number in advance I could use a Table
> pre-reservation, say Table[0,{numberofobjects}],
> to speed collocation. (I guess I could try that with
> an overestimate and then do a Take)
>
Table[] generates the elements sequentially, so it might still be
applicable to the problem. There are some other functions too, which
collect partial results (NestList, FoldList, FixedPointList are a few
examples). If it is not possible to express the algorithm with any of
these functions, there is still a fast way to collect results: Sow[]
and Reap[]. They are much faster than Append/AppendTo.
Szabolcs