adamc@850: fun foldlAbort [a] [b] [c] f =
adamc@846: let
adamc@850: fun foldlAbort' acc ls1 ls2 =
adamc@846: case (ls1, ls2) of
adamc@846: ([], []) => Some acc
adamc@846: | (x1 :: ls1, x2 :: ls2) =>
adamc@846: (case f x1 x2 acc of
adamc@846: None => None
adamc@850: | Some acc' => foldlAbort' acc' ls1 ls2)
adamc@846: | _ => None
adamc@846: in
adamc@850: foldlAbort'
adamc@846: end
adamc@846:
adamc@826: fun mapX [a] [b] [ctx ::: {Unit}] f =
adamc@801: let
adamc@801: fun mapX' ls1 ls2 =
adamc@801: case (ls1, ls2) of
adamc@801: ([], []) =>
adamc@801: | (x1 :: ls1, x2 :: ls2) => {f x1 x2}{mapX' ls1 ls2}
adamc@801: | _ => error ListPair.mapX: Unequal list lengths
adamc@801: in
adamc@801: mapX'
adamc@801: end
adamc@844:
adamc@844: fun all [a] [b] f =
adamc@844: let
adamc@844: fun all' ls1 ls2 =
adamc@844: case (ls1, ls2) of
adamc@844: ([], []) => True
adamc@844: | (x1 :: ls1, x2 :: ls2) => f x1 x2 && all' ls1 ls2
adamc@844: | _ => False
adamc@844: in
adamc@844: all'
adamc@844: end
adam@1884:
adam@1885: fun mp [a] [b] [c] (f : a -> b -> c) =
adam@1884: let
adam@1885: fun map' ls1 ls2 =
adam@1884: case (ls1, ls2) of
adam@1884: ([], []) => []
adam@1885: | (x1 :: ls1, x2 :: ls2) => f x1 x2 :: map' ls1 ls2
adam@1884: | _ => error ListPair.map2: Unequal list lengths
adam@1884: in
adam@1885: map'
adam@1884: end