Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate contains(eq, itr, item) #23716

Merged
merged 1 commit into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ Deprecated or removed
this is not true. If you are certain you need the old behavior, it is temporarily available
as `Base._isleaftype` ([#17086]).

* `contains(eq, itr, item)` is deprecated in favor of `any` with a predicate ([#23716]).

Command-line option changes
---------------------------

Expand Down
2 changes: 2 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,8 @@ import .Iterators.enumerate
return p
end

@deprecate contains(eq::Function, itr, x) any(y->eq(y,x), itr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, so that's what this method was for.


# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
32 changes: 0 additions & 32 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -637,38 +637,6 @@ const ∈ = in
∋(itr, x)= ∈(x, itr)
∌(itr, x)=!∋(itr, x)

"""
contains(fun, itr, x) -> Bool

Returns `true` if there is at least one element `y` in `itr` such that `fun(y,x)` is `true`.

```jldoctest
julia> vec = [10, 100, 200]
3-element Array{Int64,1}:
10
100
200

julia> contains(==, vec, 200)
true

julia> contains(==, vec, 300)
false

julia> contains(>, vec, 100)
true

julia> contains(>, vec, 200)
false
```
"""
function contains(eq::Function, itr, x)
for y in itr
eq(y, x) && return true
end
return false
end


## count

Expand Down
1 change: 0 additions & 1 deletion doc/src/stdlib/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ Base.flipdim
Base.circshift
Base.circshift!
Base.circcopy!
Base.contains(::Function, ::Any, ::Any)
Base.find(::Any)
Base.find(::Function, ::Any)
Base.findn
Expand Down
2 changes: 1 addition & 1 deletion test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ A = reshape(map(UInt8, 1:100), (10,10))
let A = collect(1:10)
@test A ∋ 5
@test A ∌ 11
@test contains(==,A,6)
@test any(y->y==6,A)
end

# issue #18695
Expand Down