I'm trying to define a function f
which takes a list of reals. My purpose is to build a function which I can give a list of reals, integers or strings and have it build an appropriate probability distribution for.
So I'd like to do something like
f[{samples_Real}]:=makeRealDist[samples];
f[{samples_Integer}]:=makeInteger[samples];
f[{samples_String}]:=makeCategoricalDist[samples];
I can easily match on Real
/Integer
/Strings
.
The part I can't figure out is how to match on a list of Real
/Integer
/String
.
f[{samples__Real}]
orf[samples:{__Real}]
$\endgroup$Repeated
(..
), but hereBlankSequence
(__
) is simpler. $\endgroup$3
will be rejected, but3.
will be accepted. Why not check for NumericQ? but may be you really want Real. $\endgroup$