Skip to content

Instantly share code, notes, and snippets.

@bigs
Created August 13, 2020 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigs/e03beabb6c412e9ba423c7f519c62b85 to your computer and use it in GitHub Desktop.
Save bigs/e03beabb6c412e9ba423c7f519c62b85 to your computer and use it in GitHub Desktop.
module Data.Matrix
Matrix : (m: Nat) -> (n: Nat) -> (a: Type) -> Type
Matrix m n a = Vect m (Vect n a)
madd : Num a => {n : _} -> Matrix m n a -> Matrix m n a -> Matrix m n a
madd [] [] = []
madd (x :: xs) (y :: ys) = vadd {n=n} x y :: madd xs ys
where
vadd : {n : _} -> Vect n a -> Vect n a -> Vect n a
vadd {n=Z} [] [] = []
vadd {n=(S pred)} (vx :: vxs) (vy :: vys) = (vx + vy) :: vadd {n=pred} vxs vys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment