From d2196dbd5c4379bdbc307d2035c8a07ef09b592d Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 3 Nov 2013 19:27:30 -0500 Subject: ListPair.map2, based on code by escalier@riseup.net --- lib/ur/listPair.ur | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/ur/listPair.ur') diff --git a/lib/ur/listPair.ur b/lib/ur/listPair.ur index 0182af19..d69993f9 100644 --- a/lib/ur/listPair.ur +++ b/lib/ur/listPair.ur @@ -33,3 +33,14 @@ fun all [a] [b] f = 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 ListPair.map2: Unequal list lengths + in + map2' + end -- cgit v1.2.3