Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: List element manipulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25472] Re: [mg25408] List element manipulation
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 2 Oct 2000 22:26:52 -0400 (EDT)
  • References: <gbUB5.94606$Zh6.213680@ralph.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Tomas,
Two variations on your take-apart and put together approach:

data1 = Range[1000000];

Tomas Garza

{Drop[data1, -1], Last[data1] - 1} // Flatten; // Timing // First

8.4 Second

Variations

Join[Drop[data1, -1], {Last[data1] - 1}]; // Timing // First

0.93 Second

Append[Drop[data1, -1], Last[data1] - 1]; // Timing // First

1.04 Second

The variations  are not as fast as

Module[{y = #}, y[[-1]] = y[[-1]] - 1; y] &[data1] // Timing // First

0.44 Second

and like it they are slower for more complex data, but they raise
interesting questions.


--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Tomas Garza" <tgarza01 at prodigy.net.mx> wrote in message
news:gbUB5.94606$Zh6.213680 at ralph.vnet.net...
>
> In[1]:=
> {Drop[Range[116, 166, 8], -1], Last[Range[116, 166, 8]] - 1} // Flatten
> Out[1]=
> {116, 124, 132, 140, 148, 156, 163}
>
> Tomas Garza
> Mexico City
>
> "Martin Rommel" <Martin_Rommel at mac.com> wrote:

----------- Snip -----------
>




  • Prev by Date: making a function linear
  • Next by Date: Re: Run[] in background (NT)?
  • Previous by thread: RE: List element manipulation
  • Next by thread: Re: List element manipulation