Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Simple list question
Replies: 5   Last Post: Apr 16, 2014 3:40 AM

 Messages: [ Previous | Next ]
 Richard Fateman Posts: 1,539 Registered: 12/7/04
Speed of Join and Append. Was Re: Simple list question
Posted: Apr 16, 2014 3:40 AM

On 4/14/2014 8:02 PM, Bill Rowe wrote:
> On 4/14/14 at 5:28 AM, stevebg@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.

Date Subject Author
4/14/14 Steve Gray
4/14/14 Kevin J. McCann
4/14/14 Kevin J. McCann
4/14/14 Dr. Wolfgang Hintze
4/14/14 Bill Rowe
4/16/14 Richard Fateman