2015-08-12 15:05:14 -07:00
|
|
|
|
import data.examples.vector
|
2015-01-13 11:57:14 -08:00
|
|
|
|
open nat vector prod
|
|
|
|
|
|
|
|
|
|
variables {A B : Type}
|
|
|
|
|
|
2015-02-25 16:20:44 -08:00
|
|
|
|
definition unzip : Π {n : nat}, vector (A × B) n → vector A n × vector B n
|
|
|
|
|
| @unzip ⌞zero⌟ nil := (nil, nil)
|
|
|
|
|
| @unzip ⌞succ n⌟ ((a, b) :: v) :=
|
2015-01-13 11:57:14 -08:00
|
|
|
|
match unzip v with
|
|
|
|
|
(va, vb) := (a :: va, b :: vb)
|
|
|
|
|
end
|
|
|
|
|
|
2015-10-13 15:39:03 -07:00
|
|
|
|
example : unzip ((1, 20) :: ((2, 30) : nat × nat) :: nil) = (1 :: 2 :: nil, 20 :: 30 :: nil) :=
|
2015-01-13 11:57:14 -08:00
|
|
|
|
rfl
|