[Date Index]
[Thread Index]
[Author Index]
Re: Re: More /.{I->-1} craziness
*To*: mathgroup at smc.vnet.net
*Subject*: [mg106179] Re: [mg106153] Re: More /.{I->-1} craziness
*From*: Leonid Shifrin <lshifr at gmail.com>
*Date*: Mon, 4 Jan 2010 05:59:14 -0500 (EST)
*References*: <200912300915.EAA17299@smc.vnet.net> <hhhmn8$o9t$1@smc.vnet.net>
Hi Vince,
> Replacement rules are as mathematical as 'Set' rules; to classify them
> otherwise would mislead. The simple difference between the two types
> of rules is that Replace is manual while Set is automatic. Both
> provide the math concept of 'function', and both can apply to
> structures that are non-mathematical. User discretion chooses between
> them.
>From the formal viewpoint, I must agree. But my impression is that 'Set'
rules and local rules with Replace are usually used in different
circumstances. The most common use case for 'Set' rules is arguably when a
user defines and "calls" her own function(s), since the rule substitution is
used in Mathematica to emulate the semantics of function calls. Most of
occasional users are routinely doing that using the simplest patterns like
_, and having no idea that they are using rules. And as long as their
arguments' patterns are not much more complicated, this will work fine.
Using local rules requires more sophistication, since the cases where you
might want to do that rather than define a function through 'Set' will most
likely require more complex patterns for which the transformation you want
to perform will only make sense in a specific context. Or may be you want
for some reason to avoid the full evaluation procedure. Perhaps there are
other reasons as well, but all of them seem to be aimed at doing something
that can not be easily done by taking a number of built-in functions and
just using them together - that's why I think it requires a deeper
familiarity with Mathematica. The problem is that it is much easier to look
up the Help and write a complex pattern / replacement rule, than to learn to
consistently do that correctly. With the calls to functions ('Set' rules),
things seem to be more straightforward.
> 'More advanced users' likely will find more uses for manual rule
> sets. On the other hand, they appear in Roman Maeder's introductory
> books. (Was it "Introduction to Programming in Mathematica"?)
>
Perhaps a person who can read Maeder's book and fully understand it should
no longer be afraid of using rules. But it's not an easy read - you have to
read between the lines. I have lost count of the number of times I re-read
some parts of it, and almost every time I found things that escaped me
previously (may be the reason is just me being stupid - I don't know).
Perhaps "Zen of Mathematica programming" would be a better title for it. I
think that the word "Introduction" in the title is somewhat misleading
(although it is certainly an introduction - Zen again. I am a big fan of all
his books, by the way).
Regards,
Leonid
Prev by Date:
**Re: Re: More /.{I->-1} craziness**
Next by Date:
**Combining data from indexed lists efficiently**
Previous by thread:
**Re: More /.{I->-1} craziness**
Next by thread:
**Re: Re: More /.{I->-1} craziness**
| |