Skip to main content
9 events
when toggle format what by license comment
Jun 9, 2014 at 0:45 comment added eldo @acl - ah ! now I got your interesting point. one can even write Cos[b] /. _@a___ -> a :)
Jun 9, 2014 at 0:40 comment added acl Sorry, I did not mean that your examples don't work, but that if the argument is not a then it does not get matched, because the a on the right hand side of /. is not a pattern. eg Cos[b] /. _[a] -> a evaluates to Cos[b], ie, the a is matched literally. You probably meant Cos[b] /. _[a_] -> a or, more generally (allowing for multiple arguments) Cos[b] /. _[a___] -> a.
Jun 9, 2014 at 0:33 comment added eldo @acl - Thanks - Just inspected the 4 forms by applying Head and FullForm to them - everything seems to be right.
Jun 9, 2014 at 0:25 comment added acl Your second example doesn't remove the head, it just matches _[a] with literally a then always returns a. For example Cos[b] isn't matched. I guess you meant /. _[a___] -> a, so that eg lekker[b, c] /. _[a___] -> a works.
Jun 9, 2014 at 0:20 history edited eldo CC BY-SA 3.0
added 67 characters in body
Jun 9, 2014 at 0:17 comment added eldo @Algohi- see my update :)
Jun 9, 2014 at 0:15 history edited eldo CC BY-SA 3.0
added 67 characters in body
Jun 9, 2014 at 0:11 comment added Basheer Algohi The second one is good because you can apply it to functions without need to retype the functions in Replace all. thanks eldo.
Jun 9, 2014 at 0:06 history answered eldo CC BY-SA 3.0