R: Outer Product of Sets (Tuples)

outer {sets} | R Documentation

## Outer Product of Sets (Tuples)

### Description

Outer “product” of (g)sets (tuples).

### Usage

    set_outer(X, Y, FUN = "*", ..., SIMPLIFY = TRUE, quote = FALSE)
    gset_outer(X, Y, FUN = "*", ..., SIMPLIFY = TRUE, quote = FALSE)
    cset_outer(X, Y, FUN = "*", ..., SIMPLIFY = TRUE, quote = FALSE)
    tuple_outer(X, Y, FUN = "*", ..., SIMPLIFY = TRUE, quote = FALSE)

### Arguments

`X, Y` | Set (tuple) objects or vectors. If `Y` is omitted, `X` will be used instead. In this case, `FUN` can also be specified as `Y` for convenience.
`FUN` | A function or function name (character string).
`SIMPLIFY` | Logical. If `TRUE` and all return values of `FUN` are atomic and of length 1, the result will be an atomic matrix; otherwise, a recursive one (a list with `dim` attribute).
`quote` | logical indicating whether the character strings used for the row and column names of the returned matrix should be quoted.
`...` | Additional arguments passed to the `FUN`.

### Details

This function applies `FUN` to all pairs of elements specified in `X` and `Y`. Basically intended as a replacement for `outer` for sets (tuples), it will also accept any vector for `X` and `Y`. The return value will be a matrix of dimension `length(X)` times `length(Y)`, atomic or recursive depending on the complexity of `FUN`'s return type and the `SIMPLIFY` argument.

### See Also

`set`, `tuple`, `outer`.

### Examples

    set_outer(set(1,2), set(1,2,3), "/")
    X <- set_outer(set(1,2), set(1,2,3), pair)
    X[[1,1]]
    Y <- set_outer(set(1,2), set(1,2,3), set)
    Y[[1,1]]
    set_outer(2 ^ set(1,2,3), set_is_subset)

    tuple_outer(pair(1,2), triple(1,2,3))
    tuple_outer(1:5, 1:4, "^")

[Package sets version 1.0-18 Index]