diff options
author | Adam Chlipala <adam@chlipala.net> | 2019-02-10 18:01:46 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2019-02-10 18:01:46 -0500 |
commit | b9ddbe0ce5c700fef313788fda5c7ecb82c84638 (patch) | |
tree | 6242b196f0948c3fcb6509c0ab7b33243c739f6b /lib/ur/listPair.ur | |
parent | 0aab3f48920058051d61215f23440d1042659c92 (diff) |
List.searchM and ListPair.unzip
Diffstat (limited to 'lib/ur/listPair.ur')
-rw-r--r-- | lib/ur/listPair.ur | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ur/listPair.ur b/lib/ur/listPair.ur index c5e70708..52c73cd8 100644 --- a/lib/ur/listPair.ur +++ b/lib/ur/listPair.ur @@ -58,3 +58,13 @@ fun mapM [m] (_ : monad m) [a] [b] [c] (f : a -> b -> m c) = in mapM' end + +fun unzip [a] [b] (ls : list (a * b)) : list a * list b = + let + fun unzip' ls ls1 ls2 = + case ls of + [] => (List.rev ls1, List.rev ls2) + | (x1, x2) :: ls => unzip' ls (x1 :: ls1) (x2 :: ls2) + in + unzip' ls [] [] + end |