Re: Clarification re. Curiosity concerning transformation rules for List

*To*: mathgroup at smc.vnet.net*Subject*: [mg70962] Re: [mg70947] Clarification re. Curiosity concerning transformation rules for List*From*: "Chris Chiasson" <chris at chiasson.name>*Date*: Fri, 3 Nov 2006 01:39:06 -0500 (EST)*References*: <200611021148.GAA15676@smc.vnet.net> <acbec1a40611020647h4cc56eaas403a8ff2b7cda3ad@mail.gmail.com>

heh, actually, one can't even Block List - interesting On 11/2/06, Chris Chiasson <chris at chiasson.name> wrote: > Your question was clear the last time. You could easily Block List, > and then its definitions and attributes would be yours to modify > inside the Block. > > I am not aware of any function or scoping construct that would allow > you to keep the present definitions for List and append your own such > that all the rules would be active at the same time. (though I could > think of several uses for a scoping construct with this capability - > special message handling would be one application) > > I guess the short answer to your question is: no. > > A lot of stuff would probably break if List were to have that > definition assigned. > > On 11/2/06, Andrew Moylan <andrew.j.moylan at gmail.com> wrote: > > I recently wrote: > > > > ---- > > Since the List symbol is locked, I am curious about the possibility (or > > otherwise) of giving definitions for which the left-hand-side of the > > transformation rule contains only the List symbol. Here's an arbitrary, > > explicit example: > > > > Is it possible to make a definition such that: any list of two > > identical elements evaluates to the empty list? E.g. {x_, x_} -> {}. > > > > I can't see any way this transformation rule can be added. It's not > > possible to modify the DownValues for List; and there are no > > first-level symbols to which an UpValue can be added. Does anyone have > > any ideas? > > ---- > > > > I received some replies suggesting that I use my proposed rule > > {x_,x_}->{} in combination with ReplaceAll to effect the transformation > > on a case-by-case basis. However, I am interested in whether it is > > possible to add a _definition_ so that the rule is _always_ applied. > > > > I think I can clarify by way of an example: > > > > Unprotect[Power]; > > Power[x_, x_] = 0; > > > > Now 4^3 evaluates to 64 as usual, but 4^4 evaluates to 0. However, the > > following fails because List has attribute Locked (as well as attribute > > Protected): > > > > Unprotect[List]; > > > > This doesn't mean that transformation rules involving lists cannot ever > > be defined. We can use UpValues. For example: > > > > AppendTo[UpValues[hello], {hello, x_} -> 0] > > > > Now pairs with the symbol hello as their first element evaluate to > > zero: {hello, 1} evaluates to 0. But other lists are not affected: {1, > > 2} evaluates to {1, 2}. > > > > However, the only way it was possible to add that definition was by > > attaching it as an UpValue for hello. Since there are no symbols in the > > rule {x_,x_}->{} (except List, which is locked), is it possible to make > > this definition? Is there a "global" set of transformation rules, > > always applied, but not attached to any particular symbol? > > > > I hope this is clearer, instead of less clear ;-). > > > > Cheers, > > > > Andrew > > > > > > > -- > http://chris.chiasson.name/ > -- http://chris.chiasson.name/

**References**:**Clarification re. Curiosity concerning transformation rules for List***From:*"Andrew Moylan" <andrew.j.moylan@gmail.com>