From bb97540abf26ea14881a4243b7c4b105b1a40075 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Fri, 22 Mar 2019 22:36:36 +0530 Subject: add hyperbolic trignometric functions, tabularize --- src/lex/mod.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/lex/mod.rs b/src/lex/mod.rs index c54722f..e6b2000 100644 --- a/src/lex/mod.rs +++ b/src/lex/mod.rs @@ -56,16 +56,19 @@ pub enum Token { fn get_functions() -> HashMap<&'static str, Token> { return [ - ("sin", Function::token_from_fn("sin".into(), |x| x.to_radians().sin())), - ("cos", Function::token_from_fn("cos".into(), |x| x.to_radians().cos())), - ("tan", Function::token_from_fn("tan".into(), |x| x.to_radians().tan())), - ("csc", Function::token_from_fn("csc".into(), |x| 1. / x.to_radians().sin())), - ("sec", Function::token_from_fn("sec".into(), |x| 1. / x.to_radians().cos())), - ("cot", Function::token_from_fn("cot".into(), |x| 1. / x.to_radians().tan())), - ("ln", Function::token_from_fn("ln".into(), |x| x.ln())), - ("log", Function::token_from_fn("log".into(), |x| x.log10())), - ("sqrt", Function::token_from_fn("sqrt".into(), |x| x.sqrt())), - ("ceil", Function::token_from_fn("ceil".into(), |x| x.ceil())), + ("sin", Function::token_from_fn("sin".into(), |x| x.to_radians().sin())), + ("cos", Function::token_from_fn("cos".into(), |x| x.to_radians().cos())), + ("tan", Function::token_from_fn("tan".into(), |x| x.to_radians().tan())), + ("csc", Function::token_from_fn("csc".into(), |x| x.to_radians().sin().recip())), + ("sec", Function::token_from_fn("sec".into(), |x| x.to_radians().cos().recip())), + ("cot", Function::token_from_fn("cot".into(), |x| x.to_radians().tan().recip())), + ("sinh", Function::token_from_fn("sinh".into(), |x| x.sinh())), + ("cosh", Function::token_from_fn("cosh".into(), |x| x.cosh())), + ("tanh", Function::token_from_fn("tanh".into(), |x| x.tanh())), + ("ln", Function::token_from_fn("ln".into(), |x| x.ln())), + ("log", Function::token_from_fn("log".into(), |x| x.log10())), + ("sqrt", Function::token_from_fn("sqrt".into(), |x| x.sqrt())), + ("ceil", Function::token_from_fn("ceil".into(), |x| x.ceil())), ("floor", Function::token_from_fn("floor".into(), |x| x.floor())), ].iter().cloned().collect(); } -- cgit v1.2.3