Diced

Simple algebraic dice notation parser for Gleam

Package Version Hex Docs

gleam add diced
import diced

pub fn main() {
  echo diced.parse("1d6")
  // Ok(diced.Basic(1, 6, []))
  
  echo diced.parse("5d20kh2kl2")
  // Ok(diced.Basic(5, 20, [diced.KeepHighest(2), diced.KeepLowest(2)]))
  
  echo diced.parse("1")
  // Ok(diced.Number(1, []))
  
  echo diced.parse("4dF")
  // Ok(diced.Fate(4, []))
}

Further documentation can be found at https://hexdocs.pm/diced.

Development

gleam run   # Run the project
gleam test  # Run the tests
Search Document