eva
eva copied to clipboard
`tan` takes degrees but `atan` returns radians
Shouldn't the whole system has one unit for handling angles ?
How about adding units like tan(45deg) or tan(3.14rad)
Or having a functional approach as in tan(deg(45)) while everything else remains the standard radians
I also find this a bit counter-intuitive. anyway, and have been running a slightly modified version on my machine;
git diff:
diff --git a/src/lex.rs b/src/lex.rs
index 9c12c44..69bdb45 100644
--- a/src/lex.rs
+++ b/src/lex.rs
@@ -132,12 +132,12 @@ pub static FUNCTIONS: Lazy<HashMap<&str, Token>> = Lazy::new(|| {
map.insert(token, func);
}
let mut m = HashMap::new();
- add_fn(&mut m, "sin", N1(|ctx, x| rad(ctx, x).sin()));
- add_fn(&mut m, "cos", N1(|ctx, x| rad(ctx, x).cos()));
- add_fn(&mut m, "tan", N1(|ctx, x| rad(ctx, x).tan()));
- add_fn(&mut m, "csc", N1(|ctx, x| rad(ctx, x).sin().recip()));
- add_fn(&mut m, "sec", N1(|ctx, x| rad(ctx, x).cos().recip()));
- add_fn(&mut m, "cot", N1(|ctx, x| rad(ctx, x).tan().recip()));
+ add_fn(&mut m, "sin", N1(|ctx, x| x.sin()));
+ add_fn(&mut m, "cos", N1(|ctx, x| x.cos()));
+ add_fn(&mut m, "tan", N1(|ctx, x| x.tan()));
+ add_fn(&mut m, "csc", N1(|ctx, x| x.sin().recip()));
+ add_fn(&mut m, "sec", N1(|ctx, x| x.cos().recip()));
+ add_fn(&mut m, "cot", N1(|ctx, x| x.tan().recip()));
add_fn(&mut m, "sinh", N1(|_ctx, x| x.sinh()));
add_fn(&mut m, "cosh", N1(|_ctx, x| x.cosh()));
add_fn(&mut m, "tanh", N1(|_ctx, x| x.tanh()));
and then echo "sin(rad(30))"|eva gives 0.5000000000 as expected