Shift list elements to left by 3: Difference between revisions

m (→‎{{header|AppleScript}}: →‎Two in-place alternatives: Special-cased rotations by 1 in the second script.)
Line 638:
[1, 2, 3, 4, 5, 6, 7, 8, 9] => [4, 5, 6, 7, 8, 9, 1, 2, 3]
</pre>
 
=={{header|Nim}}==
Using “rotatedLeft” from standard module “algorithm”. Note that its exists also “rotateLeft” for rotation in place.
 
<lang Nim>import algorithm
 
let list = @[1, 2, 3, 4, 5, 6, 7, 8, 9]
echo list, " → ", rotatedLeft(list, 3)</lang>
 
{{out}}
<pre>@[1, 2, 3, 4, 5, 6, 7, 8, 9] → @[4, 5, 6, 7, 8, 9, 1, 2, 3]</pre>
 
=={{header|Perl}}==
Anonymous user