Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Replacement Rule

  • To: mathgroup at
  • Subject: [mg32064] Replacement Rule
  • From: bghiggins at (Brian Higgins)
  • Date: Fri, 21 Dec 2001 03:57:42 -0500 (EST)
  • Sender: owner-wri-mathgroup at

I have the following list


and then I operate on it with the following pattern/replacement rule

In[3]:= l1 /. {x_, y_} -> x

Out[3]= {1, 3, 5}

This is what I would expect. Now consider the following list

In[4]:= l2 = {{3, 4}, {5, 6}};

Then I use the same pattern/replacement rule 

In[5]:=l2 /. {x_, y_} -> x

Out[5]= {3, 4}

I was hoping to get


What am I missing? The FullForm of l2 is basically the same structure
as l1, as far as I can tell....


  • Prev by Date: Re: equations
  • Next by Date: Solutions that are not solutions
  • Previous by thread: Re: Displaying Mathematica's Global rules
  • Next by thread: Re: Replacement Rule