DiceRoll

Run Settings
LanguageHaskell
Language Version
Run Command
module Main where import Data.List.Split import Data.Char import System.Random import System.Environment import Control.Monad type Rolls = Int type Sides = Int type Dice = (Rolls, Sides) argsToDice :: String -> Dice argsToDice args = (rolls, sides) where [rolls, sides] = map read $ splitOn "D" (map toUpper args) rollDice :: RandomGen g => Dice -> g -> Int rollDice (rolls, sides) = sum . take rolls . (randomRs (1, sides)) main :: IO () main = do args <- getArgs x <- liftM (rollDice (argsToDice (head args))) newStdGen putStrLn $ show x
Editor Settings
Theme
Key bindings
Full width
Lines