probability-0.1: Computations with discrete random variablesSource codeContentsIndex
Collection
Contents
Example collections
marbles
cards
Example
Synopsis
type Collection a = [a]
selectOne :: Eq a => Collection a -> Dist (a, Collection a)
select1 :: Eq a => Collection a -> Dist a
select2 :: Eq a => Collection a -> Dist (a, a)
selectMany :: Eq a => Int -> Collection a -> Dist ([a], Collection a)
select :: Eq a => Int -> Collection a -> Dist [a]
data Marble
= R
| G
| B
bucket :: Collection Marble
jar :: Collection Marble
pRGB :: Probability
pRG :: Probability
data Suit
= Club
| Spade
| Heart
| Diamond
data Rank
= Plain Int
| Jack
| Queen
| King
| Ace
type Card = (Rank, Suit)
plains :: [Rank]
faces :: [Rank]
isFace :: Card -> Bool
isPlain :: Card -> Bool
ranks :: [Rank]
suits :: [Suit]
deck :: Collection Card
value :: Card -> Int
draw :: ([Card], Collection Card) -> Dist ([Card], Collection Card)
drawTo16 :: t -> IO ([Card], Collection Card)
win :: ([Card], b) -> Bool
chanceWin :: IO (Dist Bool)
Documentation
type Collection a = [a]Source
selectOne :: Eq a => Collection a -> Dist (a, Collection a)Source
select1 :: Eq a => Collection a -> Dist aSource
select2 :: Eq a => Collection a -> Dist (a, a)Source
selectMany :: Eq a => Int -> Collection a -> Dist ([a], Collection a)Source
select :: Eq a => Int -> Collection a -> Dist [a]Source
Example collections
marbles
data Marble Source
Constructors
R
G
B
show/hide Instances
bucket :: Collection MarbleSource
jar :: Collection MarbleSource
pRGB :: ProbabilitySource
pRG :: ProbabilitySource
cards
data Suit Source
Constructors
Club
Spade
Heart
Diamond
show/hide Instances
data Rank Source
Constructors
Plain Int
Jack
Queen
King
Ace
show/hide Instances
type Card = (Rank, Suit)Source
plains :: [Rank]Source
faces :: [Rank]Source
isFace :: Card -> BoolSource
isPlain :: Card -> BoolSource
ranks :: [Rank]Source
suits :: [Suit]Source
deck :: Collection CardSource
Example
value :: Card -> IntSource
mini-blackjack: draw 2 cards, and if value is less than 14, continue drawing until value equals or exceeds 14. if values exceeds 21, you lose, otherwise you win.
draw :: ([Card], Collection Card) -> Dist ([Card], Collection Card)Source
drawTo16 :: t -> IO ([Card], Collection Card)Source
win :: ([Card], b) -> BoolSource
chanceWin :: IO (Dist Bool)Source
Produced by Haddock version 2.3.0