ExDiceRoller v0.5.0-alpha ExDiceRoller.Compilers.Variable

Handles compiling expressions that use variables.

Variables can be used to replace single letter characters in an expression with a value, such as a number or an anonymous function that accepts list arguments (args and opts, respectively).

iex(1)> import ExDiceRoller.Sigil
ExDiceRoller.Sigil
iex(2)> ExDiceRoller.roll(~a/1+x/, [x: 5])
6
iex(3)> ExDiceRoller.roll("xdy+z", [x: 5, y: 10, z: 50])
82
iex(4)> ExDiceRoller.roll("xdy+z", [x: 5, y: 10, z: ~a/15d100/])
739

Note that an error will be raised if values are not supplied for all varaibles in an expression.