You just need to write a function that returns false for the elements you want
to filter out. Here’s an example that does what you want:
julia> myfilter(x) = x != 0
myfilter (generic function with 1 method)
julia> A = [1, 2, 0, 4, 5, 0]
6-element Array{Int64,1}:
1
2
0
4
5
0
julia> filter(myfilter, A)
4-element Array{Int64,1}:
1
2
4
5
> On Nov 3, 2014, at 10:15 AM, Zahirul ALAM <[email protected]> wrote:
>
> The documentation says:
>
> 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).
>
> how to write the fucntion? I am trying to get elements which are nonzero. Any
> Help is much appreciated!