lean4-htt/tests/lean/run/array_simp.lean
Kim Morrison 07ea626560
feat: Array.forIn', and relate to List (#5833)
Adds support for `for h : x in my_array do`, and relates this to the
existing `List` version.
2024-10-25 07:24:39 +00:00

23 lines
571 B
Text

#check_simp #[1,2,3,4,5][2] ~> 3
#check_simp #[1,2,3,4,5][2]? ~> some 3
#check_simp #[1,2,3,4,5][7]? ~> none
#check_simp #[][0]? ~> none
#check_simp #[1,2,3,4,5][2]! ~> 3
#check_simp #[1,2,3,4,5][7]! ~> (default : Nat)
#check_simp (#[] : Array Nat)[0]! ~> (default : Nat)
attribute [local simp] Id.run in
#check_simp
(Id.run do
let mut s := 0
for i in [1,2,3,4].toArray do
s := s + i
pure s) ~> 10
attribute [local simp] Id.run in
#check_simp
(Id.run do
let mut s := 0
for h : i in [1,2,3,4].toArray do
s := s + i
pure s) ~> 10