I have a function f
, over whose source code I have no control. Is there a way for me to decorate f
so that if the evaluation time on an input exceeds, say, five seconds, the returned value is something like Missing["EvaluationThresholdReached"]
?
1 Answer
$\begingroup$
$\endgroup$
1
How about
TimeConstrained[f[whatever],5,Missing["EvaluationThresholdReached"]]
?
-
$\begingroup$ Excellent. I didn't know about this function. Thank you. $\endgroup$ Commented Sep 5, 2019 at 16:28