diff lib/ur/listPair.ur @ 1884:5c30eea7aa78

ListPair.map2, based on code by escalier@riseup.net
author Adam Chlipala <adam@chlipala.net>
date Sun, 03 Nov 2013 19:27:30 -0500
parents 1c2f335297b7
children 8297968cf7ef
line wrap: on
line diff
--- a/lib/ur/listPair.ur	Thu Oct 17 09:22:38 2013 -0400
+++ b/lib/ur/listPair.ur	Sun Nov 03 19:27:30 2013 -0500
@@ -33,3 +33,14 @@
     in
         all'
     end
+
+fun map2 [a] [b] [c] (f : a -> b -> c) =
+    let
+        fun map2' ls1 ls2 =
+            case (ls1, ls2) of
+                ([], []) => []
+              | (x1 :: ls1, x2 :: ls2) => f x1 x2 :: map2' ls1 ls2
+              | _ => error <xml>ListPair.map2: Unequal list lengths</xml>
+    in
+        map2'
+    end