I was looking at this question (here) and I tried to find any thing gives the opposite of Alternatives
. In other words, some pattern matching function that gives true when expression matches ALL patterns. Is there any function for that?
For example:
x
has to be Integer
AND Real
The other thing is that from Mr.Wizard solution, suppose I want to make a rule in which x
has to be Integer
and Real
and also x>10
, how can I define that in external rule or pattern in one shot and use pattern test ?
or pattern :
( for example to do something like this f[x_?match]
or f[x:(pattern)]
)
I hope I made the question clear.
Thank you
Integer
andReal
; those are two completely different heads. $\endgroup$x_Integer /; x > 10
works. $\endgroup$MatchQ
and&&
in the rare cases when this is necessary. For example, require that a sequence contain botha,a,a
anda,a,b
, which may or may not be overlapping. Thenseq_ /; MatchQ[seq, {___, a,a,a, ___}] && MatchQ[seq, {___, a, a, b, ___}]
. $\endgroup$