Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Richard Fateman

Posts: 1,406
Registered: 12/7/04
Speed of Join and Append. Was Re: Simple list question
Posted: Apr 16, 2014 3:40 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.