Idris2/tests/idris2/basic/basic012/VIndex.idr
2023-09-07 14:57:22 +01:00

11 lines
319 B
Idris

data Vect : Nat -> Type -> Type where
Nil : Vect Z a
(::) : a -> Vect k a -> Vect (S k) a
-- Checking that we can access 'n' from the index even though it's
-- not explicitly brought into scope, and the match requires n to be
-- Z or S k...
vlen : {n : Nat} -> Vect n a -> Nat
vlen [] = n
vlen (x :: xs) = n