Created
April 5, 2016 10:57
-
-
Save maiermic/c7b4d62843f82af3ab3a0a3fbdd2ee49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module reverse_vect | |
| import Data.Vect | |
| myReverse : Vect n a -> Vect n a | |
| myReverse [] = [] | |
| myReverse (x::xs) = (myReverse xs) ++ [x] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, it should be:
The reason that
k + 1is notS kis that+is defined to recurse on the left argument inNat. Sok + 1would not reduce any further sincekis unknown rewriting withplusCommutativeensures that the arguments are flipped so thatk + 1becomes1 + kwhich can reduce toS k. The reason that the type ofmyReverse xs ++ [x]isk + 1is because of the definition of++which adds the length of the given arguments in the resultingVect😄