Skip to content

Commit 82fc13d

Browse files
committed
Fix type stability in multiset_permutations
1 parent 6897953 commit 82fc13d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/permutations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ julia> collect(multiset_permutations([1,1,2], 3))
287287
"""
288288
function multiset_permutations(a, t::Integer)
289289
m = unique(collect(a))
290-
f = [sum([c == x for c in a]) for x in m]
290+
f = [sum(c == x for c in a)::Int for x in m]
291291
multiset_permutations(m, f, t)
292292
end
293293

test/permutations.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ end
7171
# derangements
7272
@test length(collect(derangements(1:4))) == 9
7373
@test length(collect(derangements(1:8))) == derangement(8) == 14833
74+
@test collect(derangements([])) == [[]]
7475
@test collect(derangements(Int[])) == [Int[]]
7576
@test collect(derangements([1])) == Vector{Int}[]
7677
@test collect(derangements([1, 1])) == Vector{Int}[]

0 commit comments

Comments
 (0)