Build all partitions into intervals.

all_partitions(n, kmax = n)

Arguments

n

integer, sequence lenght to choose from.

kmax

int, maximum number of segments in solution.

Value

list of all partitions.

Examples


all_partitions(4, 2)
#> [[1]]
#> [1] 1 5
#> 
#> [[2]]
#> [1] 1 2 5
#> 
#> [[3]]
#> [1] 1 3 5
#> 
#> [[4]]
#> [1] 1 4 5
#>