lean4-htt/tests/lean/run/slice.lean
Paul Reichert 1a6eae16ec
feat: introduce uLift iterator combinator, make Subarray.iter universe-polymorphic (#9027)
This PR provides an iterator combinator that lifts the emitted values
into a higher universe level via `ULift`. This combinator is then used
to make the subarray iterators universe-polymorphic. Previously, they
were only available for `Subarray α` if `α : Type`.
2025-06-27 07:34:08 +00:00

35 lines
1.1 KiB
Text

import Std.Data.Iterators
example : #[1, 2, 3][*...*].toList = [1, 2, 3] := by native_decide
example : #[1, 2, 3][*...2].toList = [1, 2] := by native_decide
example : #[1, 2, 3][*...<2].toList = [1, 2] := by native_decide
example : #[1, 2, 3][*...=1].toList = [1, 2] := by native_decide
example : #[1, 2, 3][0<...*].toList = [2, 3] := by native_decide
example : #[1, 2, 3][0<...2].toList = [2] := by native_decide
example : #[1, 2, 3][0<...<2].toList = [2] := by native_decide
example : #[1, 2, 3][0<...=1].toList = [2] := by native_decide
example : #[1, 2, 3][1...*].toList = [2, 3] := by native_decide
example : #[1, 2, 3][1...2].toList = [2] := by native_decide
example : #[1, 2, 3][1...<2].toList = [2] := by native_decide
example : #[1, 2, 3][1...=1].toList = [2] := by native_decide
example : #[1, 2, 3][1...<10].size = 2 := by native_decide
example : (#[1, 2, 3][1...*].take 1).toList = [2] := by native_decide
example : #[1, 1, 1][0...2].size = 2 := by native_decide
-- Verify that subarray iterators are universe polymorphic
def f (_ : Type) : Nat := 1
example : #[Nat, Int][*...1].toList.map f = [1] := by native_decide