diff options
| -rw-r--r-- | src/input.rs | 10 | ||||
| -rw-r--r-- | src/ui.rs | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs index 4aae623..1dde8d5 100644 --- a/src/input.rs +++ b/src/input.rs @@ -59,6 +59,16 @@ impl Calculator { *f = f.sin(); } } + "cos" => { + if let Some(f) = self.stack.last_mut() { + *f = f.cos(); + } + } + "tan" => { + if let Some(f) = self.stack.last_mut() { + *f = f.tan(); + } + } _ => { if self.input_buffer.len() > 0 { self.stack.push(self.input_buffer.parse::<f64>().unwrap()); @@ -17,7 +17,7 @@ use crate::Calculator; const WIDTH: u16 = 32; -const FUNCTIONS: [&str; 1] = ["sin"]; +const FUNCTIONS: [&str; 3] = ["sin", "cos", "tan"]; impl Calculator { pub fn draw<B: Backend>(&self, f: &mut Frame<B>) { |