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

• To: mathgroup at smc.vnet.net
• Subject: [mg63188] Re: EUREKA Re: [mg62800] Types in Mathematica, a practical example
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Sat, 17 Dec 2005 03:46:20 -0500 (EST)
• References: <43A1787000069CF6@pne-smtpout2-sn2.hy.skanova.net> (added by postmaster@pne.skanova.net)
• Sender: owner-wri-mathgroup at wolfram.com

```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.

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

```

• Prev by Date: Re: EUREKA Re: Types in Mathematica, a practical example
• Next by Date: Re: Why is y a local variable here?
• Previous by thread: Re: EUREKA Re: Types in Mathematica, a practical example
• Next by thread: Re: EUREKA Re: Types in Mathematica, a practical example