[Date Index]
[Thread Index]
[Author Index]
Re: EUREKA Re: Types in Mathematica, a practical example
*To*: mathgroup at smc.vnet.net
*Subject*: [mg63190] 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:26 -0500 (EST)
*References*: <43A1787000069CF6@pne-smtpout2-sn2.hy.skanova.net> (added by postmaster@pne.skanova.net) <DB6CBF61-D563-47BF-B707-FEFA7B843E06@mimuw.edu.pl>
*Sender*: owner-wri-mathgroup at wolfram.com
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
>> instead
>> 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}
>
> Use instead
>
>
> 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: Why is y a local variable here?**
Next by Date:
**Re: How to cope with tiny numbers in FindRoot**
Previous by thread:
**Re: EUREKA Re: Types in Mathematica, a practical example**
Next by thread:
**EUREKA Re: Types in Mathematica, a practical example**
| |