aboutsummaryrefslogtreecommitdiff
path: root/src/commonsense.rs
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-01-18 18:29:10 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2024-01-18 18:29:10 +0100
commit1713618d4cc0194674f91fd2d24ef2de88f21784 (patch)
tree1cb39a43019c071ca127cb9f609c045327798de3 /src/commonsense.rs
parent670c1881af4680ce7c248498528d14b98210af3f (diff)
create small iced demo
Diffstat (limited to 'src/commonsense.rs')
-rw-r--r--src/commonsense.rs90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/commonsense.rs b/src/commonsense.rs
deleted file mode 100644
index c42da00..0000000
--- a/src/commonsense.rs
+++ /dev/null
@@ -1,90 +0,0 @@
-use crate::complex::Complex;
-
-pub fn add(a: Complex, b: Complex) -> Complex {
- a + b
-}
-
-pub fn sub(a: Complex, b: Complex) -> Complex {
- a - b
-}
-
-pub fn mul(a: Complex, b: Complex) -> Complex {
- a * b
-}
-
-pub fn div(a: Complex, b: Complex) -> Complex {
- a / b
-}
-
-pub fn pow(a: Complex, b: Complex) -> Complex {
- a.pow(b)
-}
-
-pub fn sqrt(a: Complex) -> Complex {
- a.sqrt()
-}
-
-pub fn sin(a: Complex) -> Complex {
- a.sin()
-}
-
-pub fn cos(a: Complex) -> Complex {
- a.cos()
-}
-
-pub fn tan(a: Complex) -> Complex {
- a.tan()
-}
-
-#[macro_export]
-macro_rules! commonsense_functions {
- {$($x:expr => $y:expr), *} => {
- {
- use std::sync::Arc;
- let mut h : HashMap<String, Arc<dyn Function>> = HashMap::new();
- h.extend(functions!{
- "sqrt" => &$crate::commonsense::sqrt,
- "sin" => &$crate::commonsense::sin,
- "cos" => &$crate::commonsense::cos,
- "tan" => &$crate::commonsense::tan
- });
- $(
- h.insert($x.to_string(), Arc::new($y));
- )*
- h
- }
- };
-}
-
-#[macro_export]
-macro_rules! commonsense_operations {
- {$($x:expr => $y:expr), *} => {
- vec![
- Operation::new('+', $crate::commonsense::add),
- Operation::new('-', $crate::commonsense::sub),
- Operation::new('*', $crate::commonsense::mul),
- Operation::new('/', $crate::commonsense::div),
- Operation::new('^', $crate::commonsense::pow)
- $(
- Operation::new($x, Box::new($y)),
- )*]
- };
-}
-
-#[macro_export]
-macro_rules! commonsense_variables {
- {$($x:expr => $y:expr), *} => {
- {
- let mut h : HashMap<String, Complex> = HashMap::new();
- h.extend(variables!{
- "pi" => Complex::new(std::f64::consts::PI, 0.0),
- "e" => Complex::new(std::f64::consts::E, 0.0)
- });
- $(
- h.insert($x.to_string(), $y);
- )*
- h
- }
- };
-}
-