Shift list elements to left by 3: Difference between revisions
Shift list elements to left by 3 (view source)
Revision as of 17:24, 12 November 2023
, 6 months ago→BQN: add
(→{{header|Euler}}: Sybntax highlight with Mediawiki markup) |
(→BQN: add) |
||
Line 9:
=={{header|11l}}==
{{trans|Python}}
<syntaxhighlight lang="11l">F rotate(l, n)
V k = (l.len + n) % l.len
Line 621 ⟶ 620:
=={{header|Arturo}}==
<syntaxhighlight lang="rebol">lst: [1 2 3 4 5 6 7 8 9]
print rotate.left lst 3</syntaxhighlight>
{{out}}
<pre>4 5 6 7 8 9 1 2 3</pre>
Line 679 ⟶ 676:
new: b;c;d;a
</pre>
=={{header|BASIC}}==
Line 802 ⟶ 797:
</pre>
=={{header|BQN}}==
<syntaxhighlight lang="bqn">data ← 1 + ↕9
3 ⌽ data</syntaxhighlight>
{{out}}
<pre>⟨ 4 5 6 7 8 9 1 2 3 ⟩</pre>
=={{header|C}}==
Line 1,154 ⟶ 1,155:
next i</syntaxhighlight>
{{out}}<pre>4, 5, 6, 7, 8, 9, 1, 2, 3</pre>
=={{header|Go}}==
{{trans|Wren}}
Line 1,222 ⟶ 1,224:
=={{header|J}}==
<syntaxhighlight lang=J> 3 |. 1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3</syntaxhighlight>
However, while this matches the task example, it does not match the task title. In most contexts, a shift is different from a rotate:
<syntaxhighlight lang=J> 3 |.(!.0) 1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 0 0 0</syntaxhighlight>
Line 1,328:
"123456789" | rotateLeft(3) #=> "456789123"
</pre>
=={{header|Julia}}==
<syntaxhighlight lang="julia">list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Line 1,577 ⟶ 1,578:
=={{header|Quackery}}==
<syntaxhighlight lang="quackery">' [ 1 2 3 4 5 6 7 8 9 ] 3 split swap join echo</syntaxhighlight>
{{out}}
<pre>[ 4 5 6 7 8 9 1 2 3 ]</pre>
Line 1,703 ⟶ 1,702:
After: [4, 5, 6, 7, 8, 9, 1, 2, 3]
</pre>
=={{header|Scheme}}==
{{works with|Chez Scheme}}
|