MathGroup Archive 1997

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

Search the Archive

Re: Re: Need a new type of Hold

  • To: mathgroup at
  • Subject: [mg7599] Re: [mg7538] Re: Need a new type of Hold
  • From: daiyanh at (Daitaro Hagihara)
  • Date: Thu, 19 Jun 1997 03:14:02 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

essage-Id: <v01540b01afc9549664e3 at []>

>Ersek_Ted%PAX1A at wrote:
>> I could use a new type of Hold that is similar to HoldForm.
>> The difference is I don't want the new Hold to show up in
>> the FullForm.
>> Lets call this new feature HoldTemporary.
>> The following shows the way I want it to work.
>> (*-----------------------------------------*)
>> In[1]:=  foo=HoldTemporary[z+2+d+a+3]
>> Out[1]=  z+2+d+a+3
>> In[2]:= foo-d+4
>> Out[2]= 9+a+z
>At first I thought that what you really want to do is define your
>own addition operator, but then I decided thathat you are trying to
>do is fundamentally inconsistent with the way
>Mathematica works (I won't say "impossible", since everytime I say
>that some smart-aleck figures out a way to do it.) 
>Here's why:  
>in your first output, the 2 and the 3 don't combine.  Yet, in the second
>output, they have combined with the 9.  What should happen if I type
>"foo + b"?  Should the result be "z+2+d+a+3+b" or should it be
>"5+a+d+a+b".  Or should it be something else?  The fact is, if you want
>the 2 and 3 to combine, then they should have combined in the first
>output; if you want the order of the terms to be strictly maintained,
>then the second output should have been "z+2+d+a+7" (let's assume that
>it's okay to combine adjacent terms).  One or the other, you can't
>have it both ways.
>By the way, if it's a non-associative addition operator that you're
>after, I don't recommend removing the Orderless attribute from Plus,
>or you'll break a lot of other things.
>                Dave Wagner
>                Principia Consulting
>                Voice: (500) PRN-CPIA or (303) 258-9178
>                Fax:   (303) 258-3859


With all due respect, the question is quite legitimate and has more to do
with semantics rather than mathematics.  The case in point: consider the
Mathematica outputs something that is an intermediate step (the input
expression itself in this case) without evaluating it (or, more precisely,
after Mma determines that the problem cannot be solved in a standard way). 
You can access its InputForm, FullForm, etc., just like any other regular
output expression.  But here the output itself is held without any
Hold-related head.  There are many other similar examples where their
outputs are truly intermediate steps.  It seems that there is no way, as
far as I can tell, that users can do such a trick without rewriting the
whole thing (Mma, i.e.) from scratch and throwing in a switch or two.  It's
even somewhat surprising to see that, however mathematically correct Mma's
answer is, Identity[2+3] gives 5 instead of 2+3 (Plus[2,3]) despite
deliberately setting the HoldAll attribute first.

Though I face a more difficult problem of this kind, as far as Ted's
particular question is concerned, there is a solution (sort of).  First

SetAttributes[HoldTemporary, HoldAll];

Then we get:

z + 2 + d + a + 3

9 + a + z

Even so, Copy_Output_from_Above command doesn't work the way it's expected
to, since Out[300] was already assigned an output with HoldForm head on it,

  • Prev by Date: Re: Rank of a matrix
  • Next by Date: Re: Re: Re: Just another bug in MMA 3.0
  • Previous by thread: Re: Need a new type of Hold
  • Next by thread: Re: Need a new type of Hold