MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Clarification re. Curiosity concerning transformation rules for List

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:

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


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 ;-).



  • Prev by Date: Re: use a function within a new function
  • Next by Date: Re: use a function within a new function
  • Previous by thread: Re: Algebraic re-substitution
  • Next by thread: Re: Clarification re. Curiosity concerning transformation rules for List