Skip to content

Commit

Permalink
Move or_bool_only, and_bool_only to base/reduce.jl, ref #11774
Browse files Browse the repository at this point in the history
So these will now give MethodError for non boolean input
  • Loading branch information
tkelman committed May 27, 2016
1 parent f61ea53 commit 710e82e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,19 +387,21 @@ end
any(itr) = any(identity, itr)
all(itr) = all(identity, itr)

any(f::Any, itr) = any(Predicate(f), itr)
any(f::Any, itr) = any(Predicate(f), itr)
any(f::Predicate, itr) = mapreduce_sc_impl(f, |, itr)
any(f::typeof(identity), itr) =
any(f::typeof(identity), itr) =
eltype(itr) <: Bool ?
mapreduce_sc_impl(f, |, itr) :
reduce(or_bool_only, itr)
or_bool_only(a::Bool, b::Bool) = a | b

all(f::Any, itr) = all(Predicate(f), itr)
all(f::Any, itr) = all(Predicate(f), itr)
all(f::Predicate, itr) = mapreduce_sc_impl(f, &, itr)
all(f::typeof(identity), itr) =
eltype(itr) <: Bool ?
mapreduce_sc_impl(f, &, itr) :
reduce(and_bool_only, itr)
and_bool_only(a::Bool, b::Bool) = a & b

## in & contains

Expand Down

0 comments on commit 710e82e

Please sign in to comment.