comparison 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
comparison
equal deleted inserted replaced
1883:5125b1df6045 1884:5c30eea7aa78
31 | (x1 :: ls1, x2 :: ls2) => f x1 x2 && all' ls1 ls2 31 | (x1 :: ls1, x2 :: ls2) => f x1 x2 && all' ls1 ls2
32 | _ => False 32 | _ => False
33 in 33 in
34 all' 34 all'
35 end 35 end
36
37 fun map2 [a] [b] [c] (f : a -> b -> c) =
38 let
39 fun map2' ls1 ls2 =
40 case (ls1, ls2) of
41 ([], []) => []
42 | (x1 :: ls1, x2 :: ls2) => f x1 x2 :: map2' ls1 ls2
43 | _ => error <xml>ListPair.map2: Unequal list lengths</xml>
44 in
45 map2'
46 end