I just ran into the following subtlety.
Let us consider a function f
with attribute Orderless
.
Attributes[f]={Orderless};
For pattern matching, the consequence of this attribute is that when we have an expression with head f
, any ordering of the arguments is tested. That can be seen in the following result:
ReplaceList[ f[a,b,c], f[x_,y_, z_] :> {x,y,z} ]
(* {{a,b,c},{a,c,b},{b,a,c},{b,c,a},{c,a,b},{c,b,a}} *)
I would have expected the same result from the next command, where in the rule I catch the three arguments of f
in a BlankSequence
, thereby placing a Sequence
expression in the list at the right hand side:
ReplaceList[ f[a,b,c], f[x__] :> {x} ]
(* {{a,b,c}} *)
It only gives one result! Likely, I overlooked something simple, but I fail to see a good explanation. Why does this not work?