Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. data Vect : Nat -> Type -> Type where
  2. Nil : Vect Z a
  3. (::) : a -> Vect k a -> Vect (S k) a
  4.  
  5. exactLength : (len : Nat) -> (input : Vect m a) -> Maybe(Vect len a)
  6. exactLength {m} len input = case len == m of
  7. False => Nothing
  8. True => ?exactLength_rhs_2
  9.  
  10. data EqNat : (num1 : Nat) -> (num2 : Nat) -> Type where
  11. Same : (num : Nat) -> EqNat num num
  12.  
  13. sameS : (k : Nat) -> (j : Nat) -> (eq : EqNat k j) -> EqNat (S k) (S j)
  14. sameS j j (Same j) = Same (S j)
  15.  
  16. checkEqNat : (num1 : Nat) -> (num2 : Nat) -> Maybe (EqNat num1 num2)
  17. checkEqNat Z Z = Just (Same 0)
  18. checkEqNat Z (S k) = Nothing
  19. checkEqNat (S k) Z = Nothing
  20. checkEqNat (S k) (S j) = case checkEqNat k j of
  21. Nothing => Nothing
  22. (Just eq) => Just (sameS _ _ eq)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement