Shift list elements to left by 3: Difference between revisions

add sed
(add OCaml)
(add sed)
Line 1,606:
<pre>(list-rotate '(1 2 3 4 5 6 7 8 9) 3) --> (4 5 6 7 8 9 1 2 3)
(list-rotate '(1 2 3 4 5 6 7 8 9) -3) --> (7 8 9 1 2 3 4 5 6)</pre>
 
=={{header|sed}}==
<syntaxhighlight lang="sed"># rotate in 3 steps to easily work with lengths < 4
s/^\([^,]*\),\(.*\)/\2,\1/
s/^\([^,]*\),\(.*\)/\2,\1/
s/^\([^,]*\),\(.*\)/\2,\1/</syntaxhighlight>
{{out}}
<pre>$ echo 1,2,3,4,5,6,7,8,9 | sed -f rotate.sed
4,5,6,7,8,9,1,2,3</pre>
 
=={{header|Wren}}==
559

edits