diff --git a/README.md b/README.md index 35bd3a6..5dd5cbe 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,9 @@ Supported binary operators: | * | 100 | Product | | <= | 80 | Lower than or equal | | / | 100 | Division | | \>= | 80 | Greater than or equal | | % | 100 | Modulo | | == | 80 | Equal | -| && | 75 | Logical and | | != | 80 | Not equal | -| || | 70 | Logical or | ^ | 120 | Exponentiation | +| ^ | 120 | Exponentiation | | != | 80 | Not equal | +| && | 75 | Logical and | | , | 40 | Aggregation | +| || | 70 | Logical or | | | | | Supported unary operators: @@ -131,6 +132,7 @@ Integers are internally represented as `i64`, and floating point numbers are rep Operators that take numbers as arguments can either take integers or floating point numbers. If one of the arguments is a floating point number, all others are converted to floating point numbers as well, and the resulting value is a floating point number as well. Otherwise, the result is an integer. +An exception to this is the exponentiation operator that always returns a floating point number. Values have a precedence of 200. diff --git a/src/lib.rs b/src/lib.rs index 896779e..a908064 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,8 +93,9 @@ //! | * | 100 | Product | | <= | 80 | Lower than or equal | //! | / | 100 | Division | | \>= | 80 | Greater than or equal | //! | % | 100 | Modulo | | == | 80 | Equal | -//! | && | 75 | Logical and | | != | 80 | Not equal | -//! | || | 70 | Logical or | ^ | 120 | Exponentiation | +//! | ^ | 120 | Exponentiation | | != | 80 | Not equal | +//! | && | 75 | Logical and | | , | 40 | Aggregation | +//! | || | 70 | Logical or | | | | | //! //! Supported unary operators: //! @@ -103,6 +104,18 @@ //! | - | 110 | Negation | //! | ! | 110 | Logical not | //! +//! #### The Aggregation Operator +//! +//! The aggregation operator aggregates two values into a tuple. +//! If one of the values is a tuple already, the resulting tuple will be flattened. +//! Example: +//! +//! ```rust +//! use evalexpr::*; +//! +//! assert_eq!(eval("1, 2, 3"), Ok(Value::from(vec![Value::from(1), Value::from(2), Value::from(3)]))); +//! ``` +//! //! ### Values //! //! Operators take values as arguments and produce values as results.