Created
October 22, 2015 19:19
-
-
Save justjoheinz/05753816fb129957ca05 to your computer and use it in GitHub Desktop.
Zippy2
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 Sandbox | |
import Data.Vect | |
||| zip to Vectors of the same size | |
||| using an implicit proof | |
||| instead of zippy: Vect n e -> Vect n a -> Vect n (e,a) | |
zippy : Vect n e -> Vect m a -> {auto prf: n = m}-> Vect m (e,a) | |
zippy [] [] {prf} = [] | |
zippy (x :: xs) (y :: ys) {prf = Refl} = (x, y) :: zippy xs ys | |
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment