MathGroup Archive 1997

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

Search the Archive

Re: Re: Horse Race Puzzle (fwd)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9303] Re: [mg9259] Re: [mg9162] Horse Race Puzzle (fwd)
  • From: Olivier Gerard <jacquesg at pratique.fr>
  • Date: Mon, 27 Oct 1997 02:47:14 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Hello Robert,

Very nice rule based programming.
But the reason Mathematica is "ignoring" the Flatten is that you use an
immediate rule (->) which makes it apply the Flatten to the Pattern
when evaluating your code. You should use a delayed one (:>) (this is
not a smilie, or is it ?).

Olivier


At 07:01 +0200 97.10.24, Robert Pratt wrote:
> I omitted "{x," in the second replacement rule, which should read
> "->{x,Flatten[{y,n}],z}}".  The corrected version appears below.
>
> > The solutions can be computed recursively using pattern matching as
> > follows:
> >
> > HorseRaces[1]={{1}};
> > HorseRaces[n_]:=HorseRaces[n]=
> > 	Join[
> > Flatten[Map[ReplaceList[#,{x___,y___}->{x,n,y}]&,HorseRaces[n-1]],1],
> >    Flatten[ReplaceList[#,{x___,y_,z___}->{x,Flatten[{y,n}],z}]&,
> > 	HorseRaces[n-1]],1]
> > 	]
> >
> > Unfortunately, Mathematica seems to ignore the Flatten[{y,n}] command,
> > returning
> > {y,n} unflattened.  However, this only gives some unambiguous extra
> > nesting in the solutions.




  • Prev by Date: Re: Integration bugs in Mathematica 3.0
  • Next by Date: Re: Integrate and Distribution over terms
  • Previous by thread: RE: Horse Race Puzzle (fwd)
  • Next by thread: Integrate and Distribution over terms