Operations using indexes #
Applies a function to each element of the list along with the index at which that element is found, returning the list of results. In addition to the index, the function is also provided with a proof that the index is valid.
List.mapIdx
is a variant that does not provide the function with evidence that the index is valid.
Equations
- as.mapFinIdx f = List.mapFinIdx.go as f as #[] ⋯
Instances For
Auxiliary for mapFinIdx
:
mapFinIdx.go [a₀, a₁, ...] acc = acc.toList ++ [f 0 a₀ ⋯, f 1 a₁ ⋯, ...]
Equations
- List.mapFinIdx.go as f [] x x_1 = x.toList
- List.mapFinIdx.go as f (a :: as_1) x x_1 = List.mapFinIdx.go as f as_1 (x.push (f x.size a ⋯)) ⋯
Instances For
Applies a function to each element of the list along with the index at which that element is found, returning the list of results.
List.mapFinIdx
is a variant that additionally provides the function with a proof that the index
is valid.
Equations
- List.mapIdx f as = List.mapIdx.go f as #[]
Instances For
Auxiliary for mapIdx
:
mapIdx.go [a₀, a₁, ...] acc = acc.toList ++ [f acc.size a₀, f (acc.size + 1) a₁, ...]
Equations
- List.mapIdx.go f [] x✝ = x✝.toList
- List.mapIdx.go f (a :: as) x✝ = List.mapIdx.go f as (x✝.push (f x✝.size a))
Instances For
Applies a monadic function to each element of the list along with the index at which that element is found, returning the list of results. In addition to the index, the function is also provided with a proof that the index is valid.
List.mapIdxM
is a variant that does not provide the function with evidence that the index is
valid.
Equations
- as.mapFinIdxM f = List.mapFinIdxM.go as f as #[] ⋯
Instances For
Auxiliary for mapFinIdxM
:
mapFinIdxM.go [a₀, a₁, ...] acc = acc.toList ++ [f 0 a₀ ⋯, f 1 a₁ ⋯, ...]
Equations
- List.mapFinIdxM.go as f [] x x_1 = pure x.toList
- List.mapFinIdxM.go as f (a :: as_1) x x_1 = do let __do_lift ← f x.size a ⋯ List.mapFinIdxM.go as f as_1 (x.push __do_lift) ⋯
Instances For
Applies a monadic function to each element of the list along with the index at which that element is found, returning the list of results.
List.mapFinIdxM
is a variant that additionally provides the function with a proof that the index
is valid.
Equations
- List.mapIdxM f as = List.mapIdxM.go f as #[]
Instances For
Auxiliary for mapIdxM
:
mapIdxM.go [a₀, a₁, ...] acc = acc.toList ++ [f acc.size a₀, f (acc.size + 1) a₁, ...]
Equations
- List.mapIdxM.go f [] x✝ = pure x✝.toList
- List.mapIdxM.go f (a :: as) x✝ = do let __do_lift ← f x✝.size a List.mapIdxM.go f as (x✝.push __do_lift)