functional code

• To: mathgroup at smc.vnet.net
• Subject: [mg4845] functional code
• From: Xah Lee <xah at best.com>
• Date: Thu, 26 Sep 1996 22:42:10 -0400
• Organization: Best Internet Communications
• Sender: owner-wri-mathgroup at wolfram.com

```Some timing comparisons on elementary issues.

In[78]:=
n = 5000;

In[79]:=
li = {};
a1 = Timing[ Do[ li = {li,0}, {n}]; Flatten[li] ];

In[81]:=
li={0};
a2 = Timing@ Flatten@ Nest[ Append[li,#]&, 0, n-1];

In[83]:=
li={0};
a3 = Timing@ Flatten@ Nest[ Insert[li, #,-1]&, 0, n-1];

In[85]:=
li = {};
a4 = Timing[ Do[AppendTo[li,0], {n}]; li];

In[87]:=
First /@ {a1, a2, a3, a4}

Out[87]=
{0.233333 Second, 0.383333 Second, 0.433333 Second, 23.1167 Second}

In[88]:=
SameQ@@ (Last/@ {a1, a2, a3, a4})

Out[88]=
True

If you have time, please post other elementary methods adding to this
list.

Xah
xah at best.com; 74631.731 at compuserve.com
http://www.best.com/~xah/SpecialPlaneCurves_dir/specialPlaneCurves.html
Mountain View, CA, USA

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: Using Mma with Visual Basic & Visual C++
• Next by Date: Re: legend for multiples curves on 2-D graph with mathematica
• Previous by thread: Re: Re: functional code
• Next by thread: Re: functional code