Commit Loops
A loop is a table. init writes its first row, the while condition is its cond column, and each
primed assignment writes a cell of the next row.
acc' = acc + i reads as “the next acc is this acc plus this i”. Open the example in the
playground to see each round as a row of the trace.
def total(n: num) -> num: init: i = 1; acc = 0 while i <= n: acc' = acc + i i' = i + 1 return acc
print(total(5))Run in playground
15