Skip to content

Commit

Permalink
remove redundant definitions of argtail and tupletail
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Dec 8, 2014
1 parent 130841e commit b31a7e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ convert(::(), ::()) = ()
convert(::Type{Tuple}, x::Tuple) = x

argtail(x, rest...) = rest
tupletail(x::Tuple) = argtail(x...)
tail(x::Tuple) = argtail(x...)

convert(T::(Type, Type...), x::(Any, Any...)) =
tuple(convert(T[1],x[1]), convert(tupletail(T), tupletail(x))...)
tuple(convert(T[1],x[1]), convert(tail(T), tail(x))...)
convert(T::(Any, Any...), x::(Any, Any...)) =
tuple(convert(T[1],x[1]), convert(tupletail(T), tupletail(x))...)
tuple(convert(T[1],x[1]), convert(tail(T), tail(x))...)

convert{T}(::Type{(T...)}, x::Tuple) = cnvt_all(T, x...)
cnvt_all(T) = ()
Expand Down
5 changes: 1 addition & 4 deletions base/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ ntuple(f::Function, n::Integer) =
n==5 ? (f(1),f(2),f(3),f(4),f(5),) :
tuple(ntuple(n-2,f)..., f(n-1), f(n))

argtail(x, rest...) = rest
tail(x::Tuple) = argtail(x...)

# 0 argument function
map(f::Callable) = f()
# 1 argument function
Expand Down Expand Up @@ -90,7 +87,7 @@ const tuplehash_seed = UInt === UInt64 ? 0x77cfa1eef01bca90 : 0xf01bca90
hash(::(), h::UInt) = h + tuplehash_seed
hash(x::(Any,), h::UInt) = hash(x[1], hash((), h))
hash(x::(Any,Any), h::UInt) = hash(x[1], hash(x[2], hash((), h)))
hash(x::Tuple, h::UInt) = hash(x[1], hash(x[2], hash(tupletail(x), h)))
hash(x::Tuple, h::UInt) = hash(x[1], hash(x[2], hash(tail(x), h)))

function isless(t1::Tuple, t2::Tuple)
n1, n2 = length(t1), length(t2)
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ f6426(x,t::(Type...)) = string(t)
@test f6426(1, (1.,2.)) == "((Float64,Float64),)"

# issue #6502
f6502() = convert(Base.tupletail((Bool,Int...)), (10,))
f6502() = convert(Base.tail((Bool,Int...)), (10,))
@test f6502() === (10,)
@test convert((Bool,Int...,), (true,10)) === (true,10)
@test convert((Int,Bool...), (true,1,0)) === (1,true,false)
Expand Down

0 comments on commit b31a7e8

Please sign in to comment.