test(tests/playground/ref2): small example using [init]
This commit is contained in:
parent
d5180ffa17
commit
970ebd2b91
1 changed files with 13 additions and 0 deletions
13
tests/playground/ref2.lean
Normal file
13
tests/playground/ref2.lean
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
def init_x : io (io.ref nat) :=
|
||||
io.mk_ref 0
|
||||
|
||||
@[init init_x] constant x : io.ref nat := default _
|
||||
|
||||
def inc : io unit :=
|
||||
do v ← x.read,
|
||||
x.write (v+1),
|
||||
io.println (">> " ++ to_string v)
|
||||
|
||||
def main (xs : list string) : io unit :=
|
||||
do let n := xs.head.to_nat,
|
||||
n.mrepeat (λ _, inc)
|
||||
Loading…
Add table
Reference in a new issue