Skip to content

Commit

Permalink
add docstring for contains method (JuliaLang#19541)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenoris authored and martinholters committed Feb 7, 2017
1 parent f6fb342 commit a6600d1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,31 @@ 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
Expand Down
1 change: 1 addition & 0 deletions doc/src/stdlib/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ 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 doc/src/stdlib/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Base.search
Base.rsearch
Base.searchindex
Base.rsearchindex
Base.contains
Base.contains(::AbstractString, ::AbstractString)
Base.reverse(::AbstractString)
Base.replace
Base.split
Expand Down

0 comments on commit a6600d1

Please sign in to comment.