-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* Crate imports */ | ||
use crate::{token::Function, xprs_fn}; | ||
|
||
// sin | ||
pub const SIN: Function = xprs_fn!("sin", f64::sin, 1); | ||
pub const SINH: Function = xprs_fn!("sinh", f64::sinh, 1); | ||
pub const ASIN: Function = xprs_fn!("asin", f64::asin, 1); | ||
pub const ASINH: Function = xprs_fn!("asinh", f64::asinh, 1); | ||
// cos | ||
pub const COS: Function = xprs_fn!("cos", f64::cos, 1); | ||
pub const COSH: Function = xprs_fn!("cosh", f64::cosh, 1); | ||
pub const ACOS: Function = xprs_fn!("acos", f64::acos, 1); | ||
pub const ACOSH: Function = xprs_fn!("acosh", f64::acosh, 1); | ||
// tan | ||
pub const TAN: Function = xprs_fn!("tan", f64::tan, 1); | ||
pub const TANH: Function = xprs_fn!("tanh", f64::tanh, 1); | ||
pub const ATAN: Function = xprs_fn!("atan", f64::atan, 1); | ||
pub const ATAN2: Function = xprs_fn!("atan2", f64::atan2, 2); | ||
pub const ATANH: Function = xprs_fn!("atanh", f64::atanh, 1); | ||
// log | ||
pub const LN: Function = xprs_fn!("ln", f64::ln, 1); | ||
pub const LOG: Function = xprs_fn!("log", f64::log10, 1); | ||
pub const LOGN: Function = xprs_fn!("logn", f64::log, 2); | ||
// roots | ||
pub const SQRT: Function = xprs_fn!("sqrt", f64::sqrt, 1); | ||
pub const CBRT: Function = xprs_fn!("cbrt", f64::cbrt, 1); | ||
// misc | ||
pub const EXP: Function = xprs_fn!("exp", f64::exp, 1); | ||
pub const ABS: Function = xprs_fn!("abs", f64::abs, 1); | ||
pub const FLOOR: Function = xprs_fn!("floor", f64::floor, 1); | ||
pub const CEIL: Function = xprs_fn!("ceil", f64::ceil, 1); | ||
pub const ROUND: Function = xprs_fn!("round", f64::round, 1); | ||
pub const TRUNC: Function = xprs_fn!("trunc", f64::trunc, 1); | ||
pub const SUM: Function = xprs_fn!("sum", |args| args.iter().sum()); | ||
#[allow(clippy::as_conversions, clippy::cast_precision_loss)] | ||
pub const MEAN: Function = xprs_fn!("mean", |args| { | ||
args.iter().sum::<f64>() / args.len() as f64 | ||
}); | ||
pub const INVERT: Function = xprs_fn!("invert", f64::recip, 1); | ||
pub const MIN: Function = xprs_fn!("min", |args| { | ||
args.iter().fold(f64::INFINITY, |acc, &x| acc.min(x)) | ||
}); | ||
pub const MAX: Function = xprs_fn!("max", |args| { | ||
args.iter().fold(f64::NEG_INFINITY, |acc, &x| acc.max(x)) | ||
}); | ||
pub const HYPOT: Function = xprs_fn!("hypot", f64::hypot, 2); | ||
pub const FRACT: Function = xprs_fn!("fract", f64::fract, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* Modules */ | ||
pub mod built_in_functions; | ||
#[doc(hidden)] | ||
pub mod macros; | ||
pub mod precedence; |