Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*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 2002

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

Search the Archive

RE: Re: AppendTo VERY slow

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35355] RE: Re: AppendTo VERY slow
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Tue, 9 Jul 2002 06:49:33 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

The best solutions are

Thread[{xlist,ylist}]

and

Transpose[{xlist,ylist}]

but the Transpose version is much faster.

Bobby

-----Original Message-----
From: Dana DeLouis [mailto:delouis at bellsouth.net] 
To: mathgroup at smc.vnet.net
Subject: [mg35355]  Re: AppendTo VERY slow

I am new myself.  Would this idea work faster?

x = {1, 2, 3, 4, 5}; y = {a, b, c, d, e}; 

outlist = Thread[{x, y}]

{{1, a}, {2, b}, {3, c}, {4, d}, {5, e}}

-- 
Dana
Windows XP  & Mathematica 4.1
= = = = = = = = = = = = = = = = =

"Mike" <M.P.Croucher at Sheffield.ac.uk> wrote in message
news:ag6ed8$bnm$1 at smc.vnet.net...
> I use lists a lot in mathematica and tend to use AppendTo[] a lot in
> my programs.  Recently I wrote a function that i call over and over
> again and found that the results were coming very slowly and i MEAN
> slowly.  I was doing Fourier Transforms and all kinds of stuff so I
> put it down to those at first but I have just put in a load of Print
> statements just after each part of the function to see what was taking
> so long.
> 
> I was amazed to see that the Fourier Transforms were so quick and what
> was actually taking the time was a part of my function that collected
> the results togther in the form I wanted and outputted the result.  It
> looks like this
> 
> Do[
>     elem = {xlist[[count]], ylist[[count]]]};
>     AppendTo[outlist, elem];
>      , {count, 1, number}
>     ];
> 
> It seems that as the list grows it gets slower and slower.  Any tips
> on a way around this would be greatly appreciated (would speed my life
> up no end)
> 
> 
> Thank
> 
> Mike






  • Prev by Date: Re: Yet another Version 4.2 Integration howler
  • Next by Date: RE: Strange Behavior of AxisOrigin
  • Previous by thread: Re: AppendTo VERY slow
  • Next by thread: RE: AppendTo VERY slow