about summary refs log tree commit diff
path: root/scratch/brilliant/Utils.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-05T22·20+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-05T22·21+0100
commit244503bba91c9a99c9ab5a6a74b74d5c9bd9667e (patch)
treee26248c17d4374ab69647e461613b5bb15a1513c /scratch/brilliant/Utils.hs
parent61a2fb108dcdcc599ad9fe9de7b02d1181aec2d1 (diff)
Support App.transform
Apply the transform to a Keyboard. Onwards to the final demonstration!
Diffstat (limited to 'scratch/brilliant/Utils.hs')
-rw-r--r--scratch/brilliant/Utils.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/scratch/brilliant/Utils.hs b/scratch/brilliant/Utils.hs
index 2f401af2fb8f..c69d00333b8e 100644
--- a/scratch/brilliant/Utils.hs
+++ b/scratch/brilliant/Utils.hs
@@ -6,3 +6,8 @@ import Data.Function ((&))
 
 (|>) :: a -> (a -> b) -> b
 (|>) = (&)
+
+-- | Rotate `xs` as a cycle `n` times.
+rotate :: Int -> [a] -> [a]
+rotate n xs = take size . drop (n `mod` size) . cycle $ xs
+  where size = length xs