We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3bb39c1 commit ebba102Copy full SHA for ebba102
src/numerical_algorithms.jl
@@ -229,8 +229,8 @@ end
229
The slice corresponding to the longest run of `true`s in the vector `x`.
230
"""
231
function longest_run_of_trues(x)
232
- next_true = findnext.(Ref(.!x), eachindex(x))
233
- next_true[isnothing.(next_true)] .= 0
+ nothing2length(y) = isnothing(y) ? length(x) : y
+ next_true = nothing2length.(findnext.(Ref(.!x), eachindex(x)))
234
(len,start) = findmax(next_true .- eachindex(x))
235
start:start+len
236
end
0 commit comments