Skip to content

Commit 21ba350

Browse files
committed
Pass tests in 0.4
1 parent 282b0b1 commit 21ba350

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

src/Combinatorics.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Combinatorics
33
using Compat, Polynomials
44

55
export bell,
6-
catalan,
76
derangement,
87
doublefactorial,
98
fibonacci,
@@ -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, 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, 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, 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, UInt(n), 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, 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-

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-

0 commit comments

Comments
 (0)