diff --git a/KoiKoi.hs b/KoiKoi.hs index 00a393a..5972897 100644 --- a/KoiKoi.hs +++ b/KoiKoi.hs @@ -62,13 +62,8 @@ shuffle l = aux (length l) l where aux n [] = return [] - aux n [a] = return [a] - aux n l = do - cut <- randomRIO (0, n - 1) - let (top, bottom) = splitAt cut l - shuffledTop <- aux cut top - shuffledBottom <- aux (n - cut) bottom - reorder <- randomRIO (False, True) - return $ if reorder - then shuffledTop ++ shuffledBottom - else shuffledBottom ++ shuffledTop + aux n (h:t) = do + cut <- randomRIO (0, n-1) + shuffled <- shuffle t + let (top, bottom) = splitAt cut shuffled + return $ top ++ h : bottom