I need to define a function, say f
with an argument which is integer, positive and with a default value say 2
. I tried:
f[n_Integer?Positive:2]:=n^4-3*n+5
or
f[n_Integer:2?Positive]:=n^4-3*n+5
but it didn't work.
In this case, the first :
which is the shorthand of Pattern
cannot be omitted (yeah n_
is actually a shorthand of n : _
):
f[n : _Integer?Positive : 2] := n^4 - 3 n + 5
n
is the argument off
. $\endgroup$