f

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

```I forgot one thing: how to deal with your original problem.

In[1]:=
a=Array[Unique[a]&,{2,2}]

Out[1]=
{{a\$17,a\$18},{a\$19,a\$20}}

In[2]:=

Out[2]=
{{0,0},{0,0}}

Seems to me a little simpler than with the HoldForm approach.

Andrzej

On 17 Dec 2005, at 13:48, Andrzej Kozlowski wrote:

> If you feel really want do it in this sor of  way, I  suggest the
> following approach:
>
>
> x=Array[Unique[x]&,{2,2}]
>
>
> {{x\$23,x\$24},{x\$25,x\$26}}
>
> etc.
>
> I think in this way you get all the benefits of your approach
> without all the problems that will result from using HoldForm.
> (Somebody might have suggested this already; I have not followed
> all the suggestions carefully since I do not myself feel any need
> for a solution to this problem.)
>
> Andrzej Kozlowski
>
>
>
> On 17 Dec 2005, at 08:16, Andrzej Kozlowski wrote:
>
>>
>> On 17 Dec 2005, at 02:26, Ingolf Dahl wrote:
>>
>>>
>>>
>>> My suggestion to define a 2x2 list of undefined elements is the
>>> following:
>>>
>>> x = {{HoldForm[x[[1,1]]], HoldForm[x[[1,2]]]}, {HoldForm[x[[2,1]]],
>>> HoldForm[x[[2,2]]]}};
>>
>> You really do love this typing business ;-) Why not:
>>
>>
>> In[1]:=
>> x = Array[HoldForm[x[[##1]]] & ,
>>    {2, 2}]
>>
>> Out[1]=
>> {{HoldForm[x[[1,1]]],
>>    HoldForm[x[[1,2]]]},
>>   {HoldForm[x[[2,1]]],
>>    HoldForm[x[[2,2]]]}}
>>
>>>
>>> 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]]]}}
>>
>>
>>>
>>> Unprotect[HoldForm]; HoldForm /: Set[ HoldForm[ Part[a__]],b_]:=
>>> Set[
>>> Part[a],b]; HoldForm /: SetDelayed[ HoldForm[ Part[a__]],b_]:=
>>> SetDelayed[
>>> Part[a],b];
>>>  Protect[HoldForm];
>>
>> Since I consider redefining basic built in functions as
>> "unnecessary evil" I will stop at this. Personally I just can't
>> see any point in all of this  but of course this is just a
>> personal opinion. Those who like or imagine it could be useful it
>> can pursue this further.  However, there is just one more thing to
>> deal with:
>>
>>
>>
>>> ___________________________________________________________
>>> When I played with this, I came across the following:
>>>
>>> Assume, that the value of axxx is not defined. Then
>>>
>>> Hold[Part[axxx, 57, 62]] /. {axxx -> b}
>>>
>>> returns
>>>
>>> Hold[b[[57,62]]]
>>>
>>> but if we first assign any value to axxx, e.g. Indeterminate, we
>>> obtain
>>>
>>> Hold[axxx[[57,62]]]
>>>
>>> Can someone explain?
>>
>> This is pretty obvious and I am sure you can explain it yourself.
>> However, since you asked ..
>>
>> If aaax has the value Intermediate then in
>>
>> ReplaceAll[Hold[Part[axxx, 57, 62]], {Rule[axxx, b]}]
>>
>> the second argument evaluates to Intermediate->b, so all you are
>> doing is evaluating:
>>
>> Hold[Part[axxx, 57, 62]] /. {Intermediate -> b}
>>
>>
>>
>> Hold[axxx[[57,62]]] /.
>>   {HoldPattern[axxx] -> b}
>>
>>
>> Hold[b[[57,62]]]
>>
>>
>>
>>
>>>
>>> And I wish everybody A Merry Christmas and A Happy New Year!
>>>
>>
>> I fully agree with this!
>>
>> Andrzej Kozlowski
>

```
 0
akoz (2415)
12/18/2005 12:36:01 PM
comp.soft-sys.math.mathematica 28821 articles. 0 followers.

0 Replies
597 Views

Similar Articles

[PageSpeed] 15