**Paste:**#107063**Author(s):**1HaskellADay**Language:**Haskell**Channel:**-**Created:**2014-07-07 17:42:54 UTC

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | roll :: [a] -> Int -> [a] roll list n = let len = length list -- requires list to be finite to return rot = n `mod` len rot1 = (rot + len) `mod` len -- account for negatives (last, first) = splitAt rot1 list in first ++ last {-- Provides a solution for http://lpaste.net/107047. As was pointed out, this rolls a finite list. Is there a solution for an infinite list? Yes, perhaps, for the 'left' roll, but the 'right' roll requires knowledge of the 'tail-end' of the infinite list, so, not for the 'right'-roll that I can see. --} |