I am learning pattern matching. An example that confuse me is as follows.

Foo[x__?EvenQ] := x^2;
Foo[2, 4]

which is equal to Sequence[2,4]^2 which in turns equal to 65536.

What does it mean? Why is it 65536? I really don't understand what kind of algorithm is applied here.


1 Answer 1


Switching away from infix notation might make things more clear:

Sequence[2, 4]^2 === Power[Sequence[2, 4], 2] === Power[2, 4, 2]

According to the documentation of Power:

and so we have

Power[2, 4, 2] == 2^(4^2) == 65536

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.