package odds
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module OddsSource
Odds (Ocaml Dice Dice Something) is a library for rolling dice. It embeds the dice algebra into OCaml by providing dice rolling functions and lifting integer operations.
The type of dice expressions.
die s is an expression for rolling one die of s sides: `1ds`.
Raises Invalid_argument if s is negative.
dice n s is an expression for rolling n dice of s sides: `nds`.
Raises Invalid_argument if s is negative or if n is negative.
roll ?state t is the result of the expression t. If the state is given, it is used as a seed to roll all the dice in order. Otherwise, a state is created for the formula.
May raise Invalid_argument if any subexpression does.
val roll_fold : 
  ?state:Random.State.t ->
  folder:('acc -> int -> int -> 'acc) ->
  init:'acc ->
  'a t ->
  'a * 'accroll_fold ?state ~folder ~init t is similar to roll ?state t except that: the function folder is called on each dice roll. Specifically, folder acc s r is called where acc is the latest accumulator, s is the number of sides of the rolled dice, and r is the result.
May raise Invalid_argument if any subexpression does.
The Algebra module lifts most of the integer-related functions of the Pervasives module to apply to dice expressions.