Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. data List a where
  2. Nil :: List a
  3. Cons :: x: a -> xs: List a -> List a
  4.  
  5. data Pair a b where
  6. Pair :: a -> b -> Pair a b
  7.  
  8. termination measure len :: List a -> {Int | _v >= 0} where
  9. Nil -> 0
  10. Cons x xs -> 1 + len xs
  11.  
  12. zip :: l1:(List a) -> {List b | len _v == len l1} -> {List (Pair a b) | len _v == len l1}
  13. zip = ??
  14.  
  15. unzip :: l:(List (Pair a b)) -> (Pair {List a | len _v == len l} {List b | len _v == len l})
  16. unzip = ?? -- できない
  17.  
  18. -- ここまで書いてあげるとできるが、ほぼ答え
  19. unzip :: l:(List (Pair a b)) -> (Pair {List a | len _v == len l} {List b | len _v == len l})
  20. unzip = \l.
  21. match l with
  22. Nil -> Pair Nil Nil
  23. Cons x xs -> match unzip xs with
  24. Pair as bs -> match x with
  25. Pair a b -> ??
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement