Variable declaration reset: Difference between revisions
Content added Content deleted
Line 295: | Line 295: | ||
5 |
5 |
||
</pre> |
</pre> |
||
=={{header|jq}}== |
|||
The following "straightforward longhand loop" produces correct answers because the iteration |
|||
is specified to begin at the second element. |
|||
As it happens, if the first argument of range/2 was changed to 0, the correct results would still be correct because at the first iteration, the test would be $array[0] == $array[-1], the point being that $array[-1] evaluates to the last element of the array. |
|||
``` |
|||
[1,2,2,3,4,4,5] |
|||
| . as $array |
|||
| range(1;length) |
|||
| select( $array[.] == $array[.-1]) |
|||
``` |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |