MathGroup Archive 2005

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

Search the Archive

Re: EUREKA Re: Types in Mathematica, a practical example


On 17 Dec 2005, at 08:16, Andrzej Kozlowski wrote:

>>
>> Occasionally, when you have defined some of the undefined  
>> elements, you may
>> convert to Input Form or have to apply ReleaseHold or
>> ReplaceAll[#,HoldForm[Part[a__]]:>Part[a]]& @ to get rid of the  
>> invisible
>> HoldForm surrounding the indexed elements. For Set and SetDelayed  
>> you can
>> get this automatically by the command
>
> Hm... have you really tried it:
>
>
>
> ReplaceAll[#,HoldForm[Part[a__]]:>Part[a]]& @x
>
>
> {{HoldForm[x[[1,1]]],
>    HoldForm[x[[1,2]]]},
>   {3, HoldForm[x[[2,2]]]}}


It seems I forgot to copy and paste enough from Mathematica to make  
my point clear. So here it is more fully. Define:



x = Array[HoldForm[x[[##1]]] & , {2, 2}]


{{HoldForm[x[[1,1]]], HoldForm[x[[1,2]]]},
   {HoldForm[x[[2,1]]], HoldForm[x[[2,2]]]}}


Now set x[[1,1]] to 3

x[[1,1]] = 3; x

Out[6]=
{{3, HoldForm[x[[1,2]]]}, {HoldForm[x[[2,1]]],
    HoldForm[x[[2,2]]]}}

Let's remove HoldForm (you can use ReplaceAll[#,HoldForm[Part 
[a__]]:>Part[a]]& @ as you suggested: it won't make any difference):


x /. HoldForm -> Identity

Out[7]=
{{3, HoldForm[x[[1,2]]]}, {HoldForm[x[[2,1]]],
    HoldForm[x[[2,2]]]}}


You see, nothing changed at all because when HoldForm[x[[1,2]]] was  
released x[[1,2]] was immediately replaced by HoldForm[x[[1,2]], etc.  
In fact I completely fail to see any benefits of having HOldForm here  
compared with (for example) defining


x=Array[Unique[x]&,{2,2}]

Have I missed your point?

Andrzej Kozlowski


  • Prev by Date: Re: New MathGL3d Add-On for Mathematica Available
  • Next by Date: Re: Re: Solve Limitations
  • Previous by thread: Re: Multiple integration of UnitStep fails
  • Next by thread: Re: EUREKA Re: Types in Mathematica, a practical example