diff options
author | Adam Chlipala <adam@chlipala.net> | 2013-11-03 19:27:30 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2013-11-03 19:27:30 -0500 |
commit | d2196dbd5c4379bdbc307d2035c8a07ef09b592d (patch) | |
tree | 03de0d970495a013a2e126010600137ebb5746dd /lib/ur/listPair.ur | |
parent | 65b818146effe2f74192a3b1d65b4ec792a8a350 (diff) |
ListPair.map2, based on code by escalier@riseup.net
Diffstat (limited to 'lib/ur/listPair.ur')
-rw-r--r-- | lib/ur/listPair.ur | 11 |
1 files changed, 11 insertions, 0 deletions
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 <xml>ListPair.map2: Unequal list lengths</xml> + in + map2' + end |