Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16810 > unrolled thread
| Started by | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| First post | 2014-04-15 03:02 +0000 |
| Last post | 2014-04-16 07:40 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Simple list question Bill Rowe <readnews@sbcglobal.net> - 2014-04-15 03:02 +0000
Speed of Join and Append. Was Re: Simple list question Richard Fateman <fateman@cs.berkeley.edu> - 2014-04-16 07:40 +0000
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Date | 2014-04-15 03:02 +0000 |
| Subject | Re: Simple list question |
| Message-ID | <lii7fe$ije$1@smc.vnet.net> |
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.
[toc] | [next] | [standalone]
| From | Richard Fateman <fateman@cs.berkeley.edu> |
|---|---|
| Date | 2014-04-16 07:40 +0000 |
| Subject | Speed of Join and Append. Was Re: Simple list question |
| Message-ID | <lilc4r$qlb$1@smc.vnet.net> |
| In reply to | #16810 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web