Hi guys,

I asked this in a previous thread, but because that diverged off-topic from 
my existing question, I decided to create a new thread.

Anyhow, say I have an array

outputarray = 
Float64[-1.23423,-3.23423,-2.34234,-2.12342,1.23234,2.23423,-2.23432,5.2341,0.01111,1.23423]

This array lists the output of some function. I want to count the number of 
times that the function passes by or equals 0 while emerging from a 
negative f(x). 

In pseudocode, I want to do:

function counter(outputarray)
    count = 0
    for i in Int64[1:len(outputarray)]
        if outputarray[i] >= 0 && outputarray[i-1] < 0
            count += 1
        end
    end
    return count
end

What would be the most efficient way of doing this in Julia?

Thanks,
Wally 

Reply via email to