Re: ReplaceAll reloaded
- To: mathgroup at smc.vnet.net
- Subject: [mg107398] Re: [mg107363] ReplaceAll reloaded
- From: "David Park" <djmpark at comcast.net>
- Date: Thu, 11 Feb 2010 07:08:12 -0500 (EST)
- References: <hkeb04$t7v$1@smc.vnet.net> <4B6AB3AA.1080805@gmail.com> <4B6AB761.5060902@gmail.com> <f831b3d61002040428p72fb9984vaa8e8eb97d3e94e2@mail.gmail.com> <24193850.1265884569345.JavaMail.root@n11>
Because the Or gets evaluated on the lhs of the rule. Use HoldPattern. x = Or[a, b]; x /. HoldPattern[Or[y__]] -> {y} {a, b} But notice: Or[y__] -> {y} y__ -> {y} David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Istv=E1n Zachar [mailto:zac at freemail.hu] Can you please explain why ReplaceAll does not return a simple list? In[21]:= ClearAll[x, a, b]; x = Or[a, b]; FullForm@x Out[23]//FullForm= \!\(\* TagBox[ StyleBox[ RowBox[{"Or", "[", RowBox[{"a", ",", "b"}], "]"}], ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]\) In[24]:= x /. Or[y__] :> {y} Out[24]= {a || b} Thanks, Istvan