Jump to content

Variable declaration reset: Difference between revisions

K
(Created Nim solution.)
(K)
Line 428:
</syntaxhighlight>
 
=={{header|K}}==
There is no such thing as a <i>straightforward longhand loop</i> in K. See also: https://nsl.com/
 
A natural expression for finding the indices of repeated elements (in [[ngn/k]]) might be:<syntaxhighlight lang=K>&=/'2':1 2 2 3 4 4 5
1 4</syntaxhighlight>
 
But of course, there's no variables here.
=={{header|Nim}}==
In Nim, a loop create a new block. Variables declared in the loop body are created and initialized at each round: they do not retain the value from one round to the next.
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.