SML/NJ Library Manual


The ListXProd structure


Synopsis

signature LIST_XPROD
structure ListXProd : LIST_XPROD

The ListXProd structure provides functions for computing with the cross product of two lists. For purposes of documentation, we define the cross product of two lists as the the list produced by the following function:

fun xProd (l1, l2) = let
      fun mkPair a b = (a,b)
      in
        List.foldr (fn (a,l) => (map (mkPair a) l2)@l) [] l1
      end

Interface

val appX : (('a * 'b) -> 'c) -> ('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

appX f (l1, l2)
applies f to the cross product of the two lists. This is equivalent to:
          List.app f (xProd(l1,l2))
          


mapX f (l, l2)
creates a new list by mapping f across the cross product of the two lists. This is equivalent to:
          List.map f (xProd(l1,l2))
          


foldX f (l, l2) a
fold f across the cross product of the two lists. This is equivalent to:
          List.foldl (fn((a,b),c) => f(a,b,c)) a (xProd(l1,l2))
          



See Also

List, ListPair

[ Top | Parent | Contents | Index | Root ]

Last Modified June 11, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies