Last active
July 22, 2019 22:30
-
-
Save evanrinehart/576aa1f90199273b618e0c167d567e12 to your computer and use it in GitHub Desktop.
This file contains 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
pick :: [a] -> IO a | |
pick urn = do | |
let n = length urn | |
when (n < 1) (throwIO (userError "nothing in the urn")) | |
i <- randomRIO (0,n-1) | |
return (urn !! i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment