Skip to content

Commit dca8530

Browse files
authored
Updates for Julia 0.6 (#47)
1 parent d44f1a0 commit dca8530

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Combinatorics
22

3-
[![Combinatorics](http://pkg.julialang.org/badges/Combinatorics_0.5.svg)](http://pkg.julialang.org/?pkg=Combinatorics&ver=0.5)
3+
[![Combinatorics](http://pkg.julialang.org/badges/Combinatorics_0.5.svg)](http://pkg.julialang.org/?pkg=Combinatorics)
4+
[![Combinatorics](http://pkg.julialang.org/badges/Combinatorics_0.6.svg)](http://pkg.julialang.org/?pkg=Combinatorics)
45
[![Build Status](https://travis-ci.org/JuliaMath/Combinatorics.jl.svg?branch=master)](https://travis-ci.org/JuliaMath/Combinatorics.jl)
56
[![Coverage Status](https://coveralls.io/repos/github/JuliaMath/Combinatorics.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaMath/Combinatorics.jl?branch=master)
67
[![Codecov](https://codecov.io/gh/JuliaMath/Combinatorics.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaMath/Combinatorics.jl)

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
julia 0.5
2-
Compat 0.9.4
2+
Compat 0.18.0
33
Polynomials
44
Iterators

src/factorials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ factorial(n::Integer, k::Integer) = factorial(promote(n, k)...)
3131
"The number of permutations of n with no fixed points (subfactorial)"
3232
function derangement(sn::Integer)
3333
n = BigInt(sn)
34-
return num(factorial(n)*sum([(-1)^k//factorial(k) for k=0:n]))
34+
return numerator(factorial(n)*sum([(-1)^k//factorial(k) for k=0:n]))
3535
end
3636
subfactorial(n::Integer) = derangement(n)
3737

src/numbers.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ export bellnum,
1111
stirlings2
1212

1313
import Base: factorial, binomial
14-
14+
1515
"Returns the n-th Bell number"
1616
function bellnum(bn::Integer)
1717
if bn < 0
1818
throw(DomainError())
1919
else
2020
n = BigInt(bn)
2121
end
22-
list = Array(BigInt, div(n*(n+1), 2))
22+
list = Vector{BigInt}(div(n*(n+1), 2))
2323
list[1] = 1
2424
for i = 2:n
2525
beg = div(i*(i-1),2)
@@ -92,7 +92,7 @@ function stirlings1(n::Int, k::Int, signed::Bool=false)
9292
if signed == true
9393
return (-1)^(n - k) * stirlings1(n, k)
9494
end
95-
95+
9696
if n < 0
9797
throw(DomainError())
9898
elseif n == k == 0
@@ -110,7 +110,7 @@ function stirlings1(n::Int, k::Int, signed::Bool=false)
110110
elseif k == n - 3
111111
return binomial(n, 2) * binomial(n, 4)
112112
end
113-
113+
114114
return (n - 1) * stirlings1(n - 1, k) + stirlings1(n - 1, k - 1)
115115
end
116116

@@ -126,6 +126,6 @@ function stirlings2(n::Int, k::Int)
126126
elseif k == 2
127127
return 2^(n-1) - 1
128128
end
129-
129+
130130
return k * stirlings2(n - 1, k) + stirlings2(n - 1, k - 1)
131131
end

src/youngdiagrams.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Young diagrams, partitions of unity and characters of the symmetric group Sn #
33
################################################################################
44

5-
typealias Partition Vector{Int}
6-
typealias YoungDiagram Array{Int,2}
7-
typealias SkewDiagram Tuple{Partition, Partition}
5+
const Partition = Vector{Int}
6+
const YoungDiagram = Array{Int,2}
7+
const SkewDiagram = Tuple{Partition, Partition}
88

99
export Partition,
1010
YoungDiagram, #represents shape of Young diagram

test/permutations.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using Combinatorics
22
using Base.Test
3+
using Compat
34

45
# permutations
56
@test collect(permutations("abc")) == Any[['a','b','c'],['a','c','b'],['b','a','c'],
67
['b','c','a'],['c','a','b'],['c','b','a']]
78

8-
@test collect(filter(x->(iseven(x[1])),permutations([1,2,3]))) == Any[[2,1,3],[2,3,1]]
9-
@test collect(filter(x->(iseven(x[3])),permutations([1,2,3]))) == Any[[1,3,2],[3,1,2]]
9+
@test collect(Compat.Iterators.filter(x->(iseven(x[1])),permutations([1,2,3]))) == Any[[2,1,3],[2,3,1]]
10+
@test collect(Compat.Iterators.filter(x->(iseven(x[3])),permutations([1,2,3]))) == Any[[1,3,2],[3,1,2]]
1011

1112
@test length(permutations(0)) == 1
1213

0 commit comments

Comments
 (0)