Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.9K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to interrupt an evaluation based on a time constraint

Posted 11 years ago
POSTED BY: Hans Havermann
2 Replies

Pretty sure you just want TimeConstrained:

TimeConstrained[ code, limit] 

That will return as $Aborted, but you can also return a different failure case with the 3rd argument:

TimeConstrained[Do[i^2, {i, 1000000}], 1, $Failed]
POSTED BY: Nick Lariviere
Posted 11 years ago

Yes. That worked, thank you! Can someone confirm that Mathematica 10 is significantly less astute at PrimeQ than Mathematica 9? Timing[PrimeQ[(10^9600 78880-1)/3]] yields {7.265538,False} in 10 and {0.003482,False} in 9 (on a four-year-old iMac running Yosemite). That strikes me as a bug.

POSTED BY: Updating Name
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard