Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alunduil
Created April 8, 2020 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alunduil/313c12f0d78ee01fe12e40daf230bed4 to your computer and use it in GitHub Desktop.
Save alunduil/313c12f0d78ee01fe12e40daf230bed4 to your computer and use it in GitHub Desktop.
AlgorithmR.hs
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