Re: Delayed function does not behave as original input

• To: mathgroup at smc.vnet.net
• Subject: [mg97013] Re: Delayed function does not behave as original input
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Mon, 2 Mar 2009 05:21:16 -0500 (EST)

```On 3/1/09 at 4:56 AM, hayes.tyler at gmail.com wrote:

>I am trying to make a simple function to Riffle two lists together
>for a DateListPlot. I have attached an example below to show you
>what I am trying to do. Clearly, I am missing something basic here,
>but cannot seem to see what.

>EXAMPLE CODE

>close = {52.25`, 52.`, 52.01`, 52.06`, 52.14`, 52.45`, 52.06`,
>51.89`,
>52.06`, 52.05`};

>dates = {{2009, 2, 26, 9, 30, 0}, {2009, 2, 26, 9, 31, 0}, {2009, 2,
>26, 9, 32, 0}, {2009, 2, 26, 9, 33, 0}, {2009, 2, 26, 9, 34, 0},
>{2009, 2, 26, 9, 35, 0}, {2009, 2, 26, 9, 36, 0}, {2009, 2, 26, 9,
>37, 0}, {2009, 2, 26, 9, 38, 0}, {2009, 2, 26, 9, 39, 0}};

>closedates = Partition[Riffle[close, dates, {1, -1, 2}], 2]

>Out[178]= {{{2009, 2, 26, 9, 30, 0}, 52.25}, {{2009, 2, 26, 9, 31,
>0},
>52.}, {{2009, 2, 26, 9, 32, 0}, 52.01}, {{2009, 2, 26, 9, 33, 0},
>52.06}, {{2009, 2, 26, 9, 34, 0}, 52.14}, {{2009, 2, 26, 9, 35, 0},
>52.45}, {{2009, 2, 26, 9, 36, 0}, 52.06}, {{2009, 2, 26, 9, 37, 0},
>51.89}, {{2009, 2, 26, 9, 38, 0}, 52.06}, {{2009, 2, 26, 9, 39, 0},
>52.05}}

>(* The above is what I want *)

>dateDataMerge[datedata_, ordinatedata_] :=
>Partition[Riffle[ordinatedata, datedata, {1, -1, 2}], 2];

<error messages snipped>

On my system, your code works,

In[8]:= closedates == dateDataMerge[dates, close]

Out[8]= True

But, your code is overly complex. Using Transpose gets the same
result more efficiently. For example,

In[9]:= Partition[Riffle[close, dates, {1, -1, 2}], 2] ==
Transpose@{dates, close}

Out[9]= True

```

• Prev by Date: Re: Using Play command and polynomial tia sal2
• Next by Date: Re: Show problem: combining ListPlot and Plot
• Previous by thread: Re: Delayed function does not behave as original input
• Next by thread: Re: Delayed function does not behave as original input