Skip to content

Instantly share code, notes, and snippets.

@justjoheinz
Created October 22, 2015 19:19
Show Gist options
  • Save justjoheinz/05753816fb129957ca05 to your computer and use it in GitHub Desktop.
Save justjoheinz/05753816fb129957ca05 to your computer and use it in GitHub Desktop.
Zippy2
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