adamc@846: fun foldlPartial [a] [b] [c] f =
adamc@846: let
adamc@846: fun foldlPartial' 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@846: | Some acc' => foldlPartial' acc' ls1 ls2)
adamc@846: | _ => None
adamc@846: in
adamc@846: foldlPartial'
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