The SML of NJ Library
The `ListXProd` structure

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 function `f` to the Cartesian product of the to lists `l1` and `l2`.

`val map : (('a * 'b) -> 'c) -> ('a list * 'b list) -> 'c list`

  `mapX f (l1, l2)` maps the function `f` over the Cartesian product of the to lists `l1` and `l2` to produce a new list.

`val fold : (('a * 'b * 'c) -> 'c) -> 'c ->('a list * 'b list) -> 'c`

  `foldX f init (l1, l2)` folds the function `f` over the Cartesian product of the to lists `l1` and `l2`, using `init` 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 that `app` expects that its first argument will have a `unit` 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 of `fold` are swapped with respect to `foldX`.

## See Also

The Util Library

SML/NJ Version 110.99.3 (August 1, 2023)
Last updated 2023-07-31 17:59:01 UTC