Created
October 22, 2015 18:57
-
-
Save justjoheinz/751da5e936cef86ef587 to your computer and use it in GitHub Desktop.
Zippy.idr
This file contains 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 Sandbox | |
import Data.Vect | |
||| zip to Vectors of the same size | |
||| using a proof that n=m | |
||| instead of zippy: Vect n e -> Vect n a -> Vect n (e,a) | |
zippy : Vect n e -> Vect m a -> (n = m)-> Vect m (e,a) | |
zippy [] [] Refl = [] | |
zippy (x :: xs) (y :: ys) Refl = (x, y) :: zippy xs ys Refl | |
-- sample | |
e : Vect 3 String | |
e = ["Hello", "World", "Idris"] | |
a : Vect 3 Integer | |
a = [0,1,2] | |
result : Vect 3 (String, Integer) | |
result = zippy e a Refl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment