restart
Builtin index · REPL & diagnostics
result = restart(t)
Input: t · Output: result
What it is
Takes one argument, t (a timer object).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = restart(t) | t numbernot documented yet | result number | Returns a number: the elapsed time up to this call (the completed "lap"), then resets the object to zero and immediately starts it running again — a one-call lap/checkpoint pattern for timing each iteration of a loop. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
t = timer()
start(t)
lap1 = restart(t)
lap2 = restart(t)
pause(t)
print("lap1={lap1}, lap2={lap2}")
from repl-diagnostics
How it works
restart(t) — returns the elapsed time up to this call, then resets to zero and starts running immediately: the "lap"/ checkpoint pattern (dt = restart(t) inside a loop times each iteration and resets for the next one, in one call).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.