1
$\begingroup$

I execute a Table[] that need large time to be finished. If I abort it I loose what evaluated until now. Does it possible to stop running and save what evaluated until now?

$\endgroup$
3
  • $\begingroup$ You can add the conditional operator to save the intermediate data at certain steps of Table. $\endgroup$ Commented Feb 15, 2016 at 9:28
  • 1
    $\begingroup$ If the Table is already running then the answer is no. The partial result cannot be recovered. If you haven't started it yet, then yes, there are several ways to implement an interruptable Table. $\endgroup$ Commented Feb 15, 2016 at 9:34
  • $\begingroup$ Yes, it is running now, thanks, links are so useful. $\endgroup$ Commented Feb 15, 2016 at 9:56

1 Answer 1

0
$\begingroup$

This may be a rare case in which a combination of Do and AppendTo might be more indicated than a Table.

A simple example is the following, in which Pause[1] is a placeholder for your time-consuming computation. As soon as a new value result is available, it is appended to list, which starts out empty. If you abort the computation, list still contains the values that had been stored in it up to that point.

list = {}; Do[ Pause[1]; AppendTo[list, x], {x, 0, 10, 1} ] 

Typically this approach to creating lists is considered bad form, as it generates a copy of the existing list in memory every time it needs to add an element to list, and is generally quite slow. However, speed shouldn't be a problem for you, since it should be dominated by the computation anyway, but the memory consumption may.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.