Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Curiosity concerning transformation rules for List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70919] Re: Curiosity concerning transformation rules for List
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Wed, 1 Nov 2006 03:56:19 -0500 (EST)
  • References: <ei4ktg$dbf$1@smc.vnet.net>

Andrew Moylan 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?

In[1]:= a = Table[Random[Integer],{10},{2}]
Out[1]= {{0,1},{1,1},{0,0},{1,0},{0,0},{0,0},{1,0},{1,1},{0,0},{0,1}}

In[2]:= a /. {x_,x_}->{}
Out[2]= {{0,1},{},{},{1,0},{},{},{1,0},{},{},{0,1}}

In[3]:= a /. {x_,x_}->Sequence[]
Out[3]= {{0,1},{1,0},{1,0},{0,1}}


  • Prev by Date: Adding a key binding for a Style
  • Next by Date: Re: FindRoot, suppressing complex interval-numbers
  • Previous by thread: Re: Adding a key binding for a Style
  • Next by thread: Re: Curiosity concerning transformation rules for List