diff options
| author | Nathan Perry <avaglir@gmail.com> | 2019-03-03 21:26:14 -0500 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2019-03-03 21:26:14 -0500 |
| commit | 5af74af0ca2b5a395a83a32b88c07f7af86b3f65 (patch) | |
| tree | d8cac3ccd78980d07438bad4c7746749ba24de40 /src/commands | |
| parent | 20fe092e28b1745d50d511ea85f77b557ad62707 (diff) | |
add abs, ceil, floor, and round to roll
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/roll.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/commands/roll.rs b/src/commands/roll.rs index 16ed4da..9d130e6 100644 --- a/src/commands/roll.rs +++ b/src/commands/roll.rs @@ -72,6 +72,10 @@ impl CalcExpr { Tan => r.tan(), Factorial => statrs::function::gamma::gamma(r), Exp => r.exp(), + Abs => r.abs(), + Ceil => r.ceil(), + Floor => r.floor(), + Round => r.round(), } }, Term(v) => v, @@ -103,6 +107,10 @@ enum UnaryOp { Tan, Factorial, Neg, + Ceil, + Floor, + Abs, + Round, } fn parse_expr(input: CompleteStr) -> nom::IResult<CompleteStr, Box<CalcExpr>> { @@ -165,6 +173,10 @@ fn parse_prefix(input: CompleteStr) -> nom::IResult<CompleteStr, Box<CalcExpr>> | tag!("tan") => { |_| UnaryOp::Tan } | tag!("sgn") => { |_| UnaryOp::Sgn } | tag!("exp") => { |_| UnaryOp::Exp } + | tag!("ceil") => { |_| UnaryOp::Ceil } + | tag!("floor") => { |_| UnaryOp::Floor } + | tag!("abs") => { |_| UnaryOp::Abs } + | tag!("round") => { |_| UnaryOp::Round } | char!('-') => { |_| UnaryOp::Neg } )) >> expr: parse_term_or_paren >> |
