i have some array like this x=[2, 1, 1, 0, 1, 0, 1, 0] and i want to show only the first two elements and the last two elements of the array but when i do this x[1:2 & 7:8] it shows me this :
x=[2, 1, 1, 0, 1, 0, 1, 0]
x[1:2 & 7:8]
4-element Array{Int64,1}: 2 1 1 1
which is not true i don’t know why?
julia> 1:2 & 7:8 1:2:7
this is actually 1:(2&7):8 thus 1:2:7 you can’t just do as you feel like and expect Julia to read your mind
1:(2&7):8
1:2:7
julia> x = reverse(collect(1:8)) 8-element Array{Int64,1}: 8 7 6 5 4 3 2 1 julia> x[[1:2;7:8]] 4-element Array{Int64,1}: 8 7 2 1
this may be what you wanted
yeah that’s exactly the expected output