when I have an expression, that is unknown to mathematica, it is returned exactly the same, as it was called.
For example SeeFlyingPigs[1,2]
called on the line cames out as SeeFlyingPigs[1,2]
.
This is completely fine.
I would like to write an IF, that would cause this behaviour,
if there comes integer and a double as inputs, there would be an implementation specified and user would be presented with a result SeeFlyingPigs[1, 5.3]
output for example 31
,
But in all other cases, I want user to be returned exactly what he put in.
Till now, I tried Unevaluated[Hold[{SeeFlyingPigs[a, b]}]
- that is closest as I got, but still, the output is Hold[{SeeFlyingPigs[times[x, 2]]}]
. That is not EXACTLY what the user typed in, which was SeeFlyingPigs[6, 66]
, without the Hold, recursion is ran... (not good).
I have even tried bunch of other things, but cannot get user be given what he put in, like when no implementation is provided.
I do not want to do this by specifying the input types SeeFlyingPigs[a_Integer, b_Double]
is not what I want (for bunch of reasons).
Thanks for any help, tips, and tricks.
Condition
to your definition. Could you explain why you don't want to use_Integer
and_Real
patterns? $\endgroup$Condition
is what I was looking for. Could you post it as answer, so I can accept it? Helped a lot! $\endgroup$Condition
your function can behave exactly like function withSeeFlyingPigs[a_Integer, b_Real]
definition and the latter is more idiomatic in Mathematica. Without knowing your "bunch of reasons" for not using it, I don't really know whether it's good advice to useCondition
. $\endgroup$Mathematica
, as I recognize with every line I have to rewrite. Still,Condition
works good, as I want it to. This was my today's aim, later, I might recognize, I am wrong right now. But only by recognizing my mistakes on my own, I will be able to learn more. For now, I would leave it as is, thanks Jakub. $\endgroup$