KT
Size: a a a
KT
RS
RS
АО
RS
RS
АО
АО
ЛЛ
a = [1, 1.5, 2, 1, 6, 34, 35, 34.5]
b = reduce(a, init = [[]]) do acc, x
subarr = last(acc)
if iszero(length(subarr))
push!(acc, [x])
else
if (x > last(subarr))
push!(subarr, x)
else
push!(acc, [])
end
end
acc
end |> x -> filter(i -> length(i) != 0, x)
# 2-element Array{Array{Any,1},1}:
# [1.0, 1.5, 2.0]
# [6.0, 34.0, 35.0]
RS
ЛЛ
KT
KT
ЛЛ
RS
function partition(arr; threshold = 2.0)
local empty_arr = []
reduce(a, init = [[]]) do acc, x
local subarr = last(acc)
if isempty(subarr)
push!(acc, [x])
else
if abs(x - last(subarr)) < threshold
push!(subarr, x)
else
push!(acc, empty_arr)
end
end
acc
end |> x -> filter(i -> length(i) > 1, x)
end
RS
ЛЛ
function partition(arr; threshold = 2.0)
local empty_arr = []
reduce(a, init = [[]]) do acc, x
local subarr = last(acc)
if isempty(subarr)
push!(acc, [x])
else
if abs(x - last(subarr)) < threshold
push!(subarr, x)
else
push!(acc, empty_arr)
end
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]