Skip to content

Commit 3771edd

Browse files
committed
Merge pull request #4 from dlfivefifty/master
0.4 compatibility
2 parents 5e3d1b3 + d7349ab commit 3771edd

File tree

6 files changed

+24
-28
lines changed

6 files changed

+24
-28
lines changed

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
julia 0.3
1+
julia 0.3+
22
Compat
3-
Polynomial
3+
Polynomials

src/Combinatorics.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module Combinatorics
22

3-
using Compat, Polynomial
3+
using Compat, Polynomials
44

55
export bell,
6-
catalan,
76
derangement,
87
doublefactorial,
98
fibonacci,
@@ -50,7 +49,7 @@ function catalan(bn::Integer)
5049
div(binomial(2*n, n), (n + 1))
5150
end
5251

53-
# The number of permutations of n with no fixed points (subfactorial)
52+
# The number of permutations of n with no fixed points (subfactorial)
5453
function derangement(sn::Integer)
5554
n = BigInt(sn)
5655
return num(factorial(n)*sum([(-1)^k//factorial(k) for k=0:n]))
@@ -63,7 +62,7 @@ function doublefactorial(n::Integer)
6362
end
6463
z = BigInt()
6564
ccall((:__gmpz_2fac_ui, :libgmp), Void,
66-
(Ptr{BigInt}, Uint), &z, uint(n))
65+
(Ptr{BigInt}, UInt), &z, @compat(UInt(n)))
6766
return z
6867
end
6968

@@ -73,7 +72,7 @@ function fibonacci(n::Integer)
7372
end
7473
z = BigInt()
7574
ccall((:__gmpz_fib_ui, :libgmp), Void,
76-
(Ptr{BigInt}, Uint), &z, uint(n))
75+
(Ptr{BigInt}, UInt), &z, @compat(UInt(n)))
7776
return z
7877
end
7978

@@ -110,7 +109,7 @@ function lucas(n::Integer)
110109
end
111110
z = BigInt()
112111
ccall((:__gmpz_lucnum_ui, :libgmp), Void,
113-
(Ptr{BigInt}, Uint), &z, uint(n))
112+
(Ptr{BigInt}, UInt), &z, @compat(UInt(n)))
114113
return z
115114
end
116115

@@ -120,7 +119,7 @@ function multifactorial(n::Integer, m::Integer)
120119
end
121120
z = BigInt()
122121
ccall((:__gmpz_mfac_uiui, :libgmp), Void,
123-
(Ptr{BigInt}, Uint, Uint), &z, uint(n), uint(m))
122+
(Ptr{BigInt}, UInt, UInt), &z, @compat(UInt(n)), @compat(UInt(m)))
124123
return z
125124
end
126125

@@ -141,7 +140,7 @@ function primorial(n::Integer)
141140
end
142141
z = BigInt()
143142
ccall((:__gmpz_primorial_ui, :libgmp), Void,
144-
(Ptr{BigInt}, Uint), &z, uint(n))
143+
(Ptr{BigInt}, UInt), &z, @compat(UInt(n)))
145144
return z
146145
end
147146

src/partitions.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function integer_partitions(n::Integer)
1515
list = Vector{Int}[]
1616

1717
for p in integer_partitions(n-1)
18-
push!(list, [p, 1])
18+
push!(list, [p; 1])
1919
if length(p) == 1 || p[end] < p[end-1]
20-
push!(list, [p[1:end-1], p[end]+1])
20+
push!(list, [p[1:end-1]; p[end]+1])
2121
end
2222
end
2323

@@ -95,4 +95,3 @@ function ncpart(a::Integer, b::Integer, nn::Integer,
9595
end
9696
end
9797
end
98-

src/youngdiagrams.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
typealias Partition Vector{Int64}
66
typealias YoungDiagram Array{Int64,2}
7-
typealias SkewDiagram (Partition, Partition)
7+
typealias SkewDiagram @compat(Tuple{Partition,Partition})
88

9-
export Partition,
9+
export Partition,
1010
YoungDiagram, #represents shape of Young diagram
11-
SkewDiagram, #skew diagrams
11+
SkewDiagram, #skew diagrams
1212
partitionsequence,
1313
isrimhook, #Check if skew diagram is rim hook
1414
leglength,
@@ -158,5 +158,3 @@ function character(λ::Partition, μ::Partition)
158158
Λ▔ = partitionsequence(λ)
159159
MN1inner(Λ▔, T, μ, 1)
160160
end
161-
162-

test/basic.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# catalan
2-
@test catalan(5) == 42
3-
@test catalan(30) == BigInt("3814986502092304")
2+
@test Combinatorics.catalan(5) == 42
3+
@test Combinatorics.catalan(30) == parse(BigInt,"3814986502092304")
44

55
# derangement
66
@test derangement(4) == 9
7-
@test derangement(24) == BigInt("228250211305338670494289")
7+
@test derangement(24) == parse(BigInt,"228250211305338670494289")
88

99
# doublefactorial
10-
@test doublefactorial(70) == BigInt("355044260642859198243475901411974413130137600000000")
10+
@test doublefactorial(70) == parse(BigInt,"355044260642859198243475901411974413130137600000000")
1111

1212
# fibonacci
1313
@test fibonacci(5) == 5
14-
@test fibonacci(101) == BigInt("573147844013817084101")
14+
@test fibonacci(101) == parse(BigInt,"573147844013817084101")
1515

1616
# hyperfactorial
17-
@test hyperfactorial(8) == BigInt("55696437941726556979200000")
17+
@test hyperfactorial(8) == parse(BigInt,"55696437941726556979200000")
1818

1919
# lassalle
20-
@test lassalle(14) == BigInt("270316008395632253340")
20+
@test lassalle(14) == parse(BigInt,"270316008395632253340")
2121

2222
# legendresymbol
2323
@test legendresymbol(1001,9907) == jacobisymbol(1001,9907) == -1
2424

2525
# lucas
2626
@test lucas(10) == 123
27-
@test lucas(100) == BigInt("792070839848372253127")
27+
@test lucas(100) == parse(BigInt,"792070839848372253127")
2828

2929
# multifactorial
3030
@test multifactorial(40,2) == doublefactorial(40)
@@ -40,10 +40,9 @@
4040

4141
# bell
4242
@test bell(7) == 877
43-
@test bell(42) == BigInt("35742549198872617291353508656626642567")
43+
@test bell(42) == parse(BigInt,"35742549198872617291353508656626642567")
4444
@test_throws DomainError bell(-1)
4545

4646
# integer_partitions
4747
@test integer_partitions(5) == Any[[1, 1, 1, 1, 1], [2, 1, 1, 1], [2, 2, 1], [3, 1, 1], [3, 2], [4, 1], [5]]
4848
@test_throws DomainError integer_partitions(-1)
49-

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Combinatorics
22
using Base.Test
3+
using Compat
34
include("basic.jl")
45
include("youngdiagrams.jl")
56

0 commit comments

Comments
 (0)