Consider this example:
Cases[{4, x, 5 a , 6 x}, x_.*a_ :> x]
(*{1, 1, 5, 6}*)
It is clear that the _.
took 1 as a Default value.
Now:
f[x_.] := {x}
dose not work and _.
Default value has to be user defined first
Default[f] = 0;
f[x_.] := {x}
f[]
(*{0}*)
It is little confusing that _.
takes default value in some operation and has to be user defined with default value in other operation.
Any explanations?
Thanks
Times
,Plus
,Power
have built-in default values (1, 0, and 1, respectively). $\endgroup$DefaultValues[Times]
,DefaultValues[Plus]
etc. to see this. Now tryDefaultValues[f]
before you have attached any default values to it, and you will see thatf
has no built-in default values. $\endgroup$