1
$\begingroup$

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"]?

$\endgroup$

1 Answer 1

4
$\begingroup$

How about

TimeConstrained[f[whatever],5,Missing["EvaluationThresholdReached"]]

?

$\endgroup$
1
  • $\begingroup$ Excellent. I didn't know about this function. Thank you. $\endgroup$ Commented Sep 5, 2019 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.