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?
Asked
Active
Viewed 55 times
1
jack cilba
- 357
- 1
- 9
1 Answers
0
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.
MarcoB
- 67,153
- 18
- 91
- 189
Table. – Rom38 Feb 15 '16 at 09:28Tableis 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. – Szabolcs Feb 15 '16 at 09:34