aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-03-22 17:06:36 +0000
committerNerdyPepper <[email protected]>2019-03-22 17:06:36 +0000
commitbb97540abf26ea14881a4243b7c4b105b1a40075 (patch)
tree90e582c88a0556848870027acff4e90e8759febe
parent313cfa0cb3c79329c4507e72ec681027f20fad2e (diff)
add hyperbolic trignometric functions, tabularize
-rw-r--r--src/lex/mod.rs23
1 files 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 {
56 56
57fn get_functions() -> HashMap<&'static str, Token> { 57fn get_functions() -> HashMap<&'static str, Token> {
58 return [ 58 return [
59 ("sin", Function::token_from_fn("sin".into(), |x| x.to_radians().sin())), 59 ("sin", Function::token_from_fn("sin".into(), |x| x.to_radians().sin())),
60 ("cos", Function::token_from_fn("cos".into(), |x| x.to_radians().cos())), 60 ("cos", Function::token_from_fn("cos".into(), |x| x.to_radians().cos())),
61 ("tan", Function::token_from_fn("tan".into(), |x| x.to_radians().tan())), 61 ("tan", Function::token_from_fn("tan".into(), |x| x.to_radians().tan())),
62 ("csc", Function::token_from_fn("csc".into(), |x| 1. / x.to_radians().sin())), 62 ("csc", Function::token_from_fn("csc".into(), |x| x.to_radians().sin().recip())),
63 ("sec", Function::token_from_fn("sec".into(), |x| 1. / x.to_radians().cos())), 63 ("sec", Function::token_from_fn("sec".into(), |x| x.to_radians().cos().recip())),
64 ("cot", Function::token_from_fn("cot".into(), |x| 1. / x.to_radians().tan())), 64 ("cot", Function::token_from_fn("cot".into(), |x| x.to_radians().tan().recip())),
65 ("ln", Function::token_from_fn("ln".into(), |x| x.ln())), 65 ("sinh", Function::token_from_fn("sinh".into(), |x| x.sinh())),
66 ("log", Function::token_from_fn("log".into(), |x| x.log10())), 66 ("cosh", Function::token_from_fn("cosh".into(), |x| x.cosh())),
67 ("sqrt", Function::token_from_fn("sqrt".into(), |x| x.sqrt())), 67 ("tanh", Function::token_from_fn("tanh".into(), |x| x.tanh())),
68 ("ceil", Function::token_from_fn("ceil".into(), |x| x.ceil())), 68 ("ln", Function::token_from_fn("ln".into(), |x| x.ln())),
69 ("log", Function::token_from_fn("log".into(), |x| x.log10())),
70 ("sqrt", Function::token_from_fn("sqrt".into(), |x| x.sqrt())),
71 ("ceil", Function::token_from_fn("ceil".into(), |x| x.ceil())),
69 ("floor", Function::token_from_fn("floor".into(), |x| x.floor())), 72 ("floor", Function::token_from_fn("floor".into(), |x| x.floor())),
70 ].iter().cloned().collect(); 73 ].iter().cloned().collect();
71} 74}