From 5af74af0ca2b5a395a83a32b88c07f7af86b3f65 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Sun, 3 Mar 2019 21:26:14 -0500 Subject: add abs, ceil, floor, and round to roll --- src/commands/roll.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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> { @@ -165,6 +173,10 @@ fn parse_prefix(input: CompleteStr) -> nom::IResult> | 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 >> -- cgit v1.3.1