Created
May 9, 2014 01:07
-
-
Save shoooe/1022282d815dc6690d5d to your computer and use it in GitHub Desktop.
Simple algorithm to draw 6 numbers in the range [1..49], implemented in Haskell, as an exercise with Data.Set.
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
import qualified Data.Set as Set | |
import System.Random (randomRIO) | |
import Control.Monad (return) | |
type Numbers = Set.Set Int | |
draw :: Int -> Numbers -> IO Numbers | |
draw i s = | |
if ((Set.size s) == i) then return s | |
else do | |
n <- randomRIO (1, 49) | |
draw i $ Set.insert n s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment