Skip to main content
9 events
when toggle format what by license comment
Nov 15, 2015 at 0:09 comment added SquareOne @mathers101 In that case my answer would have been: expr /. Power[x_, n_Integer] -> x //. Times[p[x_], p[y_]] /; IntersectingQ[x, y] :> p[Union[x, y]]
Nov 13, 2015 at 15:09 vote accept Alex Mathers
Nov 13, 2015 at 15:08 comment added Alex Mathers @SquareOne the idea is that the repeated element gets combined into a single element, because even though it's the same it has elements in common. Thanks for your post though.
Nov 13, 2015 at 10:42 comment added SquareOne It is not clear why in your post you say you need the repeating p[{2,3}] while in your comment you show that at the end you don't take into account this repeated element ... ?
Nov 13, 2015 at 9:38 answer added SquareOne timeline score: 3
Nov 13, 2015 at 8:56 comment added xzczd How about this?: Times @@ p /@ Union @@@ Gather[ p[{1, 2}] p[{2, 3}]^2 p[{4, 5}] /. a_^b_ :> a /. HoldPattern@Times[a__] :> Sequence @@@ {a}, Intersection[#, #2] != {} &]
Nov 13, 2015 at 8:40 comment added Alex Mathers The replacement is essentially just combining components that have elements in common. So my example would get replaced by p[{1,2,3}] p[{4,5}]. I actually think I've found a way around it, although not in the most elegant way.
Nov 13, 2015 at 8:21 comment added xzczd What's the replacement you want to do? Maybe you can work around the problem by modifying the replacing rule.
Nov 13, 2015 at 8:14 history asked Alex Mathers CC BY-SA 3.0