Skip to contents

This function generates all unique pairs of integers up to a given number.

Usage

getUniquePairsUpTo(x, oneIndexed = TRUE)

Arguments

x

An integer specifying the upper limit for pairs.

oneIndexed

A logical indicating whether the pairs should be one indexed. Default is TRUE.

Value

A list of unique pairs of integers up to the specified number.

Examples

# Generate unique pairs up to 3 (one-indexed)
getUniquePairsUpTo(3)
#> [[1]]
#> [1] 1 2
#> 
#> [[2]]
#> [1] 1 3
#> 
#> [[3]]
#> [1] 2 3
#> 
# Generate unique pairs up to 3 (zero-indexed)
getUniquePairsUpTo(3, oneIndexed = FALSE)
#> [[1]]
#> [1] 0 1
#> 
#> [[2]]
#> [1] 0 2
#> 
#> [[3]]
#> [1] 1 2
#>