Erlang Cyclic Rotation
-module(cyclic_rotation).
-export([cyclic_rotation/2]).
cyclic_rotation([], _K) ->
[];
cyclic_rotation(A, K) ->
N = length(A),
Shift = K rem N,
{Front, Back} = lists:split(N - Shift, A),
Back ++ Front.
This rotates the array to the right by K steps and keeps the wrap-around values in the correct order.