Files
lean4/tests/playground/ref2.lean
2019-03-21 18:30:58 -07:00

14 lines
278 B
Lean4

def initX : IO (IO.Ref Nat) :=
IO.mkRef 0
@[init initX] constant x : IO.Ref Nat := default _
def inc : IO Unit :=
do v x.get,
x.set (v+1),
IO.println (">> " ++ toString v)
def main (xs : List String) : IO Unit :=
do let n := xs.head.toNat,
n.mrepeat (λ _, inc)