Created
April 8, 2020 05:31
-
-
Save alunduil/313c12f0d78ee01fe12e40daf230bed4 to your computer and use it in GitHub Desktop.
AlgorithmR.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AlgorithmR | |
( algorR | |
) | |
where | |
algorR :: Num a => Int -> Int -> [a] -> ([a], [a]) | |
algorR = algorR' ([], []) | |
algorR' :: Num a => ([a], [a]) -> Int -> Int -> [a] -> ([a], [a]) | |
algorR' (ys, zs) _ 0 _ = (ys, zs) | |
algorR' (ys, zs) n t (x : xs) = algorR' a' (n - 1) (t - 1) xs | |
where a' = if chance n t then (ys ++ [x], zs) else (ys, zs ++ [x]) | |
chance :: Int -> Int -> Bool | |
chance _ _ = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment