mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-24 05:12:29 +03:00
9c902de5d1
We can't refine by a name in Rig0 because we can't assume it covers all possibilities, so only refine by them at the end, at which point we check that there's only one case left (otherwise we have to match on it, which is not allowed for an erased thing)
21 lines
492 B
Idris
21 lines
492 B
Idris
data Vect : Nat -> Type -> Type where
|
|
Nil : Vect Z a
|
|
(::) : a -> Vect k a -> Vect (S k) a
|
|
|
|
append : Vect n a -> Vect m a -> Vect (n + m) a
|
|
append [] ys = ys
|
|
-- append (x :: xs) ys = x :: append xs ys
|
|
|
|
data Fin : Nat -> Type where
|
|
FZ : Fin (S k)
|
|
FS : Fin k -> Fin (S k)
|
|
|
|
lookup : Fin n -> Vect n a -> a
|
|
lookup FZ (x :: xs) = x
|
|
lookup (FS k) (x :: xs) = lookup k xs
|
|
|
|
zip : Vect n a -> Vect n b -> Vect n (a, b)
|
|
zip [] [] = []
|
|
zip (x :: xs) (y :: ys) = (x, y) :: zip xs ys
|
|
|