This PR introduces polymorphic slices in their most basic form. They come with a notation similar to the new range notation. `Subarray` is now also a slice and can produce an iterator now. It is intended to migrate more operations of `Subarray` to the `Slice` wrapper type to make them available for slices of other types, too. The PR also moves the `filterMap` combinators into `Init` because they are used internally to implement iterators on array slices.
31 lines
990 B
Text
31 lines
990 B
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
|