MathGroup Archive 2009

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

Search the Archive

Re: Delayed function does not behave as original input

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97026] Re: [mg96992] Delayed function does not behave as original input
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Mon, 2 Mar 2009 05:23:43 -0500 (EST)
  • References: <200903010956.EAA04324@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

Both sets of code do the same thing, here.

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}};
good = Partition[Riffle[close, dates, {1, -1, 2}], 2]

{{{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}}

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

{{{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}}

bad == good

True

I suspect you had an earlier (buggy) definition of dateDataMerge and  
failed to Clear it before using the new (debugged) definition. That  
wouldn't matter if both signatures were the same or the new signature were  
more specific... but if the earlier definition had a MORE specific  
signature, like dateDataMerge[datedata_List, ordinatedata_List], it would  
take precedence over the newer, less specific signature.

Bobby

On Sun, 01 Mar 2009 03:56:34 -0600, <hayes.tyler at gmail.com> wrote:

> Hello All:
>
> 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];
>
> closedatesbad = dateDataMerge[dates, close]
>
> During evaluation of In[180]:= Riffle::list: List expected at position
> 1 in Riffle[52.25,2009,{1,-1,2}]. >>
>
> During evaluation of In[180]:= Riffle::list: List expected at position
> 1 in Riffle[52.25,2009]. >>
>
> During evaluation of In[180]:= Riffle::argtu: Riffle called with 1
> argument; 2 or 3 arguments are expected. >>
>
> During evaluation of In[180]:= Riffle::list: List expected at position
> 1 in Riffle[52.25,2,{1,-1,2}]. >>
>
> During evaluation of In[180]:= General::stop: Further output of
> Riffle::list will be suppressed during this calculation. >>
>
>
> END OF EXAMPLE CODE
>
> Any help is appreciated.
>
> Cheers,
>
> t.
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: Delayed function does not behave as original input
  • Next by Date: Re: Delayed function does not behave as original input
  • Previous by thread: Re: Delayed function does not behave as original input
  • Next by thread: Re: Delayed function does not behave as original input