I am reading this page : https://reference.wolfram.com/language/tutorial/FunctionsWithVariableNumbersOfArguments.html
And I don't understand the example : h[a___, x_, b___, x_, c___] := hh[x] h[a, b, c]
At the exact first call, which vales take x,a,b,c on the call ? Because I am confused with thoose ___.
x_
represents any two duplicated elements, anda
,b
,c
with blank null sequence pattern can represent anything. Togetherh
will pick out duplicated elements regardless of their positions. If your first call refers toh[2, 3, 2, 4, 5, 3]
, thena
isSequence[]
(Nothing
),b
is 3,c
isSequence[4,5,3]
andx
is2
, the expression becomes ` hh[2] h[3,4,5,3]. Then the latter part can also be matched, with
a` isSequence[]
,b
isSequence[4,5]
,c
isSequence[]
andx
is3
, then the final answer ish[4, 5] hh[2] hh[3]
$\endgroup$