Shift list elements to left by 3: Difference between revisions
m
→AppleScript :: Prefix appended
(→AppleScript :: Functional: Added a variant – sample of an infinite cycle) |
|||
Line 85:
-- rotated :: Int -> [a] -> [a]
on rotated(n, xs)
set m to |mod|(n, length of xs)▼
if 0 ≠ n then
▲ set m to |mod|(n, length of xs)
(items (1 + m) thru -1 of xs) & ¬
(items 1 thru m of xs)
Line 203:
Rotated 3 left: {4, 5, 6, 7, 8, 9, 1, 2, 3}
Rotated 3 right: {7, 8, 9, 1, 2, 3, 4, 5, 6}</pre>
====Cycle sampled====
|