lean4-htt/tests/lean/run/numChars.lean

24 lines
430 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def numChars (s : String) : Nat :=
go s.iter
where
go (i : String.Iterator) : Nat :=
if h : i.hasNext then
go i.next + 1
else
0
#eval numChars "aαc"
example : numChars "aαc" = 3 := by
rfl'
def numChars2 (s : String) : Nat :=
go s.iter
where
go (i : String.Iterator) : Nat :=
match h : i.hasNext with
| true => go i.next + 1
| false => 0
example : numChars2 "aαc" = 3 := by
rfl'