MathGroup Archive 2014

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

Search the Archive

Speed of Join and Append. Was Re: Simple list question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132596] Speed of Join and Append. Was Re: Simple list question
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Wed, 16 Apr 2014 03:40:06 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <lii7fe$ije$1@smc.vnet.net>

On 4/14/2014 8:02 PM, Bill Rowe wrote:
> On 4/14/14 at 5:28 AM, stevebg at roadrunner.com (Ste[hen Gray) wrote:
>
>> pcin = 2;
>> pcex = 3;   (*pcin and pcex can have various small values *)
>>
>> coin = Table[{10 RandomReal[], 10 RandomReal[]}, {pcin}]
>> coex = Table[{3 RandomReal[], 3 RandomReal[]}, {pcex}]
>> cobo = Append[coin, coex]
>> pcin = 2;
>> pcex = 3;   (*pcin and pcex can have various small values *)
>>
>> coin = Table[{10 RandomReal[], 10 RandomReal[]}, {pcin}]
>> coex = Table[{3 RandomReal[], 3 RandomReal[]}, {pcex}]
>> cobo = Append[coin, coex]
>
> <snip>
>
>> What I want is a series of x,y coordinates with no extra nesting:
>
> Instead of Append, use Join, i.e.
>
> cobo = Join[coin, coex]
>
> In fact, Append is something to generally avoid using
> particularly for large arrays due to the computing resources
> used. It will require more memory and is slower. Won't matter
> for small arrays like this. But for large arrays, Append is very
> much a problem and better replaced with other commands such as Join.
>
>

You are, I think, confusing the conventional implementation of lists,
append and cons from Lisp, and the peculiar implementation in 
Mathematica of Append and Join.

I expect that in Mathematica they are equally wasteful, because
lists are represented by arrays and must be copied whether to
join or append.





  • Prev by Date: Re: Using FindRoot with free parameters
  • Next by Date: Three masses and four springs
  • Previous by thread: Re: Simple list question
  • Next by thread: Three masses and four springs