Iguales al siguiente en Julia
This commit is contained in:
10
src/Julia/001.jl
Normal file
10
src/Julia/001.jl
Normal 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[]
|
||||
Reference in New Issue
Block a user