next | previous | forward | backward | up | index | toc

# nextOrderedPartition -- iterates over ordered partitions of a number

## Synopsis

• Usage:
P = nextOrderedPartition(n,Lists)
P' = nextOrderedPartition(P,n,Lists)
• Inputs:
• Outputs:
• P', a list, the next ordered partition, if any

## Description

Given an integer $n$ and lists $L_1,\ldots,L_k$ of distinct nonnegative integers, this method iterates over all tuples $(l_1,\ldots,l_k)$ such that $\sum_i l_i = n$ and $l_i\in L_i$. The tuples are produced one at a time.

Returns "null" if none.

 i1 : L = {{0,1},{0,1,2},{2,3}}; i2 : P = nextOrderedPartition (5,L) o2 = {0, 2, 3} o2 : List i3 : P = nextOrderedPartition (P,5,L) o3 = {1, 1, 3} o3 : List i4 : P = nextOrderedPartition (P,5,L) o4 = {1, 2, 2} o4 : List i5 : assert(nextOrderedPartition (P,5,L) === null)

## Ways to use nextOrderedPartition :

• "nextOrderedPartition(List,ZZ,List)"
• "nextOrderedPartition(ZZ,List)"

## For the programmer

The object nextOrderedPartition is .