MathGroup Archive 2001

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

Search the Archive

Re: Replacement Rule


Try
yourList/.{x_?AtomQ,y_AtomQ}->x


On Friday 21 December 2001 09:57, Brian Higgins wrote:
> I have the following list
>
> l1={{1,2},{3,4},{5,6}};
>
> 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
>
> {3,5}
>
> What am I missing? The FullForm of l2 is basically the same structure
> as l1, as far as I can tell....
>
> Brian


  • Prev by Date: Re: Is this a bug?
  • Next by Date: Re: Replacement Rule
  • Previous by thread: Replacement Rule
  • Next by thread: Re: Replacement Rule