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 functionf
to the Cartesian product of the to listsl1
andl2
.
val map : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list
-
mapX f (l1, l2)
maps the functionf
over the Cartesian product of the to listsl1
andl2
to produce a new list.
val fold : (('a * 'b * 'c) -> 'c) -> 'c ->('a list * 'b list) -> 'c
-
foldX f init (l1, l2)
folds the functionf
over the Cartesian product of the to listsl1
andl2
, usinginit
as 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
app
instead. Note thatapp
expects that its first argument will have aunit
return type. val mapX : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list
-
Use
map
instead. val foldX : (('a * 'b * 'c) -> 'c) -> 'c ->('a list * 'b list) -> 'c
-
Use
fold
instead. Note that the second and third arguments offold
are swapped with respect tofoldX
.