# Pattern Matching BlankSequence

Consider the definition:

Clear[fun]
fun[a_ + b_] := fun[a] + fun[b];
fun[a+b+c]
(*fun[a] + fun[b] + fun[c]*)


This works as expected. However, if we use a BlankSequence on "b":

Clear[fun]
fun[a_ + b__] := fun[a] + fun[b];
fun[a + b + c]
(*fun[a] + fun[b, c]*)


it seems that BlankSequence eliminates the Plus in "b+c" and replaces it with Sequence. Has anybody a good explanation for this behaviour?

a+b+c == Plus[a,b,c]

So fun[a_ + b__]  == fun[Plus[a_, b__]]

when input a + b + c,which equals Plus[a,b,c] , mma match b with b,c

a + b + c /. a_ + b__ :> {a, {b}}


{a, {b, c}}

• Hi, here a follow up question: Can you explain why the "b" in the following expression gets lost?: Clear[fu] fu[a_ + b__] := fu[a] + fu[(Print[FullForm@Hold@b]; b)]; fu[a + b + c] Oct 5, 2020 at 8:59
• @DanielHuber I tried these 2 code: a + b + c /. a_ + b__ :> {{a}, {None; b}} and a + b + c /. a_ + b__ :> {{a}, {b}} , find something interesting. I am not able to explain it. Oct 5, 2020 at 10:00
• HI, the same happens with any symbol you like. E.g.a + b + c /. a_ + b__ :> {{a}, {gaga; b}} There are some mysteries with BlankSequence that I do not understand Oct 5, 2020 at 10:20