Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: this is ridiculous...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61818] Re: [mg61798] this is ridiculous...
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Mon, 31 Oct 2005 01:17:11 -0500 (EST)
  • References: <200510300443.AAA09812@smc.vnet.net> <56AAC040-65FB-4E4F-A971-9E14ECF71207@earthlink.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Summary:

As suggested by more than one person:

Equal[d, 2] /. HoldPattern[Equal[x__]] :> tree[x]

HoldPattern prevents a left hand side (rule) evaluation that I was not
expecting.

My thanks go to Selwyn, Bob, and Steven (the responders so far).

Regards,

On 10/30/05, Selwyn Hollis <sh2.7183 at earthlink.net> wrote:
> Chris,
>
> Equal[x__] evaluates to True (as does Equal[]). HoldPattern is the fix:
>
> In:    Equal[d, 2] /. HoldPattern[Equal[x__]] :> tree[x]
>
> Out:   tree[d,2]
>
> ---
>   Selwyn Hollis
>
>
> On Oct 30, 2005, at 12:43 AM, Chris Chiasson wrote:
>
> > Can anyone replicate the pattern replacement problem I am having
> > with Equal?
> >
> > Cell[CellGroupData[{Cell[BoxData[{
> >     RowBox[{
> >       RowBox[{"Equal", "[",
> >         RowBox[{"d", ",", "2"}], "]"}], "/.",
> >       RowBox[{
> >         RowBox[{"Equal", "[", "x__", "]"}], "\[RuleDelayed]",
> >         RowBox[{"tree", "[", "x", "]"}]}]}], "\[IndentingNewLine]",
> >     RowBox[{
> >       RowBox[{"willow", "[",
> >         RowBox[{"d", ",", "2"}], "]"}], "/.",
> >       RowBox[{
> >         RowBox[{"willow", "[", "x__", "]"}], "\[RuleDelayed]",
> >         RowBox[{"tree", "[", "x", "]"}]}]}], "\[IndentingNewLine]",
> >   "$Version"}], "Input",
> >   CellLabel->"In[1]:="],
> >
> > Cell[BoxData[
> >     RowBox[{"d", "\[Equal]", "2"}]], "Output",
> >   CellLabel->"Out[1]="],
> >
> > Cell[BoxData[
> >     RowBox[{"tree", "[",
> >       RowBox[{"d", ",", "2"}], "]"}]], "Output",
> >   CellLabel->"Out[2]="],
> >
> > Cell[BoxData["\<\"5.2 for Microsoft Windows (June 20, 2005)\"\>"], \
> > "Output",
> >   CellLabel->"Out[3]="]
> > }, Open  ]]
> >
> > --
> > http://chrischiasson.com/contact/chris_chiasson
> >
> >
>
>


--
http://chrischiasson.com/contact/chris_chiasson


  • Prev by Date: Re: SymbolName question
  • Next by Date: Re: Question regarding Mathematica's treatment of whitespace
  • Previous by thread: this is ridiculous...
  • Next by thread: Re: this is ridiculous...