feat(library/init/data/list): add unzip

This commit is contained in:
Johannes Hölzl 2017-02-20 11:07:53 -05:00 committed by Leonardo de Moura
parent 4c88e2c5b0
commit 16aaa9b88e

View file

@ -167,6 +167,10 @@ def zip_with (f : α → β → γ) : list α → list β → list γ
def zip : list α → list β → list (prod α β) :=
zip_with prod.mk
def unzip : list (α × β) → list α × list β
| [] := ([], [])
| ((a, b) :: t) := match unzip t with (al, bl) := (a::al, b::bl) end
def repeat (a : α) : → list α
| 0 := []
| (succ n) := a :: repeat n