@@ -136,12 +136,47 @@ Base.length(f::FixedPartitions) = npartitions(f.n,f.m)
136136Base. eltype (f:: FixedPartitions ) = Vector{Int}
137137
138138"""
139- partitions(n, m)
139+ partitions(n::Integer , m::Integer )
140140
141- Generate all arrays of `m` integers that sum to `n`. Because the number of partitions can
142- be very large, this function returns an iterator object. Use `collect(partitions(n, m))` to
143- get an array of all partitions. The number of partitions to generate can be efficiently
144- computed using `length(partitions(n, m))`.
141+ Generate all integer partitions of `n` into exactly `m` parts, that sum to `n`.
142+
143+ Because the number of partitions can be very large,
144+ this function returns an iterator object.
145+ Use `collect(partitions(n, m))` to get an array of all partitions.
146+
147+ The number of partitions to generate can be efficiently computed using
148+ `length(partitions(n, m))`.
149+
150+ See also: [`partitions(n::Integer)`](@ref)
151+
152+ ## Examples
153+ ```jldoctest
154+ julia> collect(partitions(4))
155+ 5-element Vector{Vector{Int64}}:
156+ [4]
157+ [3, 1]
158+ [2, 2]
159+ [2, 1, 1]
160+ [1, 1, 1, 1]
161+
162+ julia> collect(partitions(4, 2))
163+ 2-element Vector{Vector{Int64}}:
164+ [3, 1]
165+ [2, 2]
166+
167+ julia> collect(partitions(4, 4))
168+ 1-element Vector{Vector{Int64}}:
169+ [1, 1, 1, 1]
170+
171+ julia> collect(partitions(4, 5))
172+ Vector{Int64}[]
173+
174+ julia> partitions(4, 0)
175+ ERROR: DomainError with (4, 0):
176+ n and m must be positive
177+ Stacktrace:
178+ [...]
179+ ```
145180"""
146181partitions (n:: Integer , m:: Integer ) =
147182 n >= 1 && m >= 1 ?
0 commit comments