Variable declaration reset: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
|||
Line 337: | Line 337: | ||
6 |
6 |
||
</pre> |
</pre> |
||
Parenthetical note: making a global variable to support a for loop has a bad code smell in Julia. A better |
|||
way to do such a comparison of adjacent values in an array is to alter the start of the loop variable: |
|||
<lang julia> |
|||
s = [1, 2, 2, 3, 4, 4, 5] |
|||
for i in eachindex(s)[begin+1:end] # or 2:length(s) |
|||
s[i] == s[i - 1] && println(i) |
|||
end |
|||
</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |