The ListXProd structure provides list combinators for computing
over the "Cartesian product" of two lists. For lists [a, b, c]
and [x, y, z], the elements are processed in the order
[ (a, x), (a, y), (a, z),
(b, x), (b, y), (b, z),
(c, x), (c, y), (c, z)
]
Synopsis
signature LIST_XPROD
structure ListXProd : LIST_XPROD
Interface
val app : (('a * 'b) -> unit) -> ('a list * 'b list) -> unit
val map : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list
val fold : (('a * 'b * 'c) -> 'c) -> 'c -> ('a list * 'b list) -> 'c
val appX : (('a * 'b) -> unit) -> ('a list * 'b list) -> unit
val mapX : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list
val foldX : (('a * 'b * 'c) -> 'c) -> ('a list * 'b list) -> 'c -> 'c
Description
val app : (('a * 'b) -> unit) -> ('a list * 'b list) -> unit-
appX f (l1, l2)applies the functionfto the Cartesian product of the to listsl1andl2.
val map : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list-
mapX f (l1, l2)maps the functionfover the Cartesian product of the to listsl1andl2to produce a new list.
val fold : (('a * 'b * 'c) -> 'c) -> 'c ->('a list * 'b list) -> 'c-
foldX f init (l1, l2)folds the functionfover the Cartesian product of the to listsl1andl2, usinginitas the initial value.
Deprecated functions
The following functions are part of the interface, but have been deprecated.
val appX : (('a * 'b) -> 'c) -> ('a list * 'b list) -> unit-
Use
appinstead. Note thatappexpects that its first argument will have aunitreturn type. val mapX : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list-
Use
mapinstead. val foldX : (('a * 'b * 'c) -> 'c) -> 'c ->('a list * 'b list) -> 'c-
Use
foldinstead. Note that the second and third arguments offoldare swapped with respect tofoldX.