Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.
|
|
|
Re: [mg4898] Transformation rule exercise
Posted:
Oct 9, 1996 2:06 PM
|
|
To: xah@best.com Subject: Re: [mg4898] Transformation rule exercise Newsgroups: comp.soft-sys.math.mathematica In-Reply-To: <53a61p$noo@dragonfly.wolfram.com> Organization: University of Maryland, Baltimore County Cc: Bcc:
In article <53a61p$noo@dragonfly.wolfram.com> you write: >> Date: Fri, 4 Oct 1996 00:17:36 -0400 >> From: rhall2@umbc.edu (hall robert) >> To: mathgroup@smc.vnet.net >> Subject: [mg4898] Transformation rule exercise >> ... exercise 4 from p. 113 of >> Introduction to Programming with Mathematica, by Gaylord, Kamin & Wellin. >> The problem is to rewrite >> g[x_] = x /. Plus[z___] -> Times[z] >> so that >> g[a + b + c] >> returns >> a b c >>... >> I'm looking for a solution to which the >> authors' hint applies... > >I'm not sure what if the following is what you are looking for. > >g[x_] := ReleaseHold[ Hold[ Plus[3,4,5] ] /. Plus->Times]
Specified input is "a + b + c", specified output is "a b c". In[31]:= g[a + b + c] Out[31]= 60
Nope, that's not it.
Rewriting g[] so that x appears in the lhs; In[40]:= g[x_] := ReleaseHold[Hold[x] /. Plus -> Times] In[41]:= g[a + b + c] Out[41]= a b c
But ReleaseHold[] and Hold[] are unnecessary. One of my original solutions was In[42]:= g[x_] := x /. Plus -> Times In[43]:= g[a + b + c] Out[43]= a b c
Thanks to all who emailed responses, but I think we're wasting our time. I think there's a typo in either the problem or the hint. The two don't seem to be related.
-- Bob Hall | "Know thyself? Absurd direction! rhall2@gl.umbc.edu | Bubbles bear no introspection." -Khushhal Khan Khatak
|
|
|
|