shithub: MicroHs

Download patch

ref: af9153ddf9e2bdbfb4a4dbd5fa3e360746f36bb9
parent: 88b845ec25cb28b081ec98b2a2d1e345815b2f9b
author: Lennart Augustsson <lennart@augustsson.net>
date: Sat Dec 23 03:49:39 EST 2023

Slightly faster unzip

--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -185,6 +185,8 @@
 
 -- XXX not as lazy as it could be
 unzip :: forall a b . [(a, b)] -> ([a], [b])
+unzip xys = (map fst xys, map snd xys)  -- this version is slightly faster than the other two
+{-
 unzip axys =
   case axys of
     [] -> ([], [])
@@ -191,6 +193,13 @@
     (x,y) : xys ->
       case unzip xys of
         (xs, ys) -> (x:xs, y:ys)
+-}
+{-
+unzip [] = ([], [])
+unzip ((x,y) : xys) =
+  let (xs, ys) = unzip xys
+  in  (x:xs, y:ys)
+-}
 
 -- XXX not as lazy as it could be
 unzip3 :: forall a b c . [(a, b, c)] -> ([a], [b], [c])
--