ЛЛ
Size: a a a
ЛЛ
RS
function partition(arr; threshold = 2.0)
reduce(a, init = [Float64[]]) do acc, x
local subarr = last(acc)
if isempty(subarr) || abs(x - last(subarr)) > threshold
push!(acc, [x])
else
push!(subarr, x)
end
acc
end |> x -> filter(i -> length(i) > 1, x)
end
a = [100, 38, 1, 1.5, 2, 1, 6, 34, 35, 34.5, 10, 23, 11, 11.5, 12, 11.8, 11.4]
b = partition(a)
RS
julia> b
3-element Array{Array{Float64,1},1}:
[1.0, 1.5, 2.0, 1.0]
[34.0, 35.0, 34.5]
[11.0, 11.5, 12.0, 11.8, 11.4]
RS
ЛЛ
function partition(arr; threshold = 2.0)
reduce(a, init = [Float64[]]) do acc, x
local subarr = last(acc)
if isempty(subarr) || abs(x - last(subarr)) > threshold
push!(acc, [x])
else
push!(subarr, x)
end
acc
end |> x -> filter(i -> length(i) > 1, x)
end
a = [100, 38, 1, 1.5, 2, 1, 6, 34, 35, 34.5, 10, 23, 11, 11.5, 12, 11.8, 11.4]
b = partition(a)
KT
RS
abs(x - last(subarr)) > threshold заменить last на first, или mean и пр.RS
ЛЛ
АО
ЛЛ
push!RS
ЛЛ
АО
АО
ЛЛ
АО
ЛЛ
RS
ЛЛ