Skip to content

Commit

Permalink
Attach filter's docstring to the AbstractArray filter fallback (r…
Browse files Browse the repository at this point in the history
…ather than an Iterators.filter method not pulled into Base). (#19057)
  • Loading branch information
Sacha0 authored and tkelman committed Oct 26, 2016
1 parent 59a4d1c commit dee3c54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
20 changes: 19 additions & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,25 @@ end

## Filter ##

# given a function returning a boolean and an array, return matching elements
"""
filter(function, collection)
Return a copy of `collection`, removing elements for which `function` is `false`. For
associative collections, the function is passed two arguments (key and value).
```jldocttest
julia> a = 1:10
1:10
julia> filter(isodd, a)
5-element Array{Int64,1}:
1
3
5
7
9
```
"""
filter(f, As::AbstractArray) = As[map(f, As)::AbstractArray{Bool}]

function filter!(f, a::Vector)
Expand Down
19 changes: 0 additions & 19 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,6 @@ immutable Filter{F,I}
itr::I
end

"""
filter(function, collection)
Return a copy of `collection`, removing elements for which `function` is `false`. For
associative collections, the function is passed two arguments (key and value).
```jldocttest
julia> a = 1:10
1:10
julia> filter(isodd, a)
5-element Array{Int64,1}:
1
3
5
7
9
```
"""
filter(flt, itr) = Filter(flt, itr)

start(f::Filter) = start_filter(f.flt, f.itr)
Expand Down

0 comments on commit dee3c54

Please sign in to comment.