filter

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).

Examples

julia> filter((x) -> x % 3 == 0, [1:10])        # divisible by 3
3-element Array{Int64,1}:
 3
 6
 9
julia> array = Int[1,2,3]
       filter(x -> x % 2 == 0, array)
1-element Array{Int64,1}:
 2
julia> array = Int[1,2,3]
       filter(x -> x==3, array) 
1-element Array{Int64,1}:
 3

See Also

append!, delete!, deleteat!, empty!, endof, filter, filter!, gc, get!, getkey, haskey, insert!, isempty, keys, map, map!, merge, merge!, pop!, prepend!, push!, reduce, resize!, shift!, splice!, unshift!, values,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: