Iguales al siguiente en Julia

This commit is contained in:
daviddoji committed 2026-05-08 17:08:38 +02:00
1 parent 1069987fb4
commit 3546cd699f
1 file changed
+10
+10
View File
@@ -0,0 +1,10 @@
function same_to_next(lst)
return [x for (x, y) in zip(lst[1:end-1], lst[2:end]) if x == y]
end
check = [1, 2, 2, 2, 3, 3, 4]
println(same_to_next(check)) # [2, 2, 3]
check = collect(1:10)
println(same_to_next(check)) # Int64[]