Fixed basic problems

This commit is contained in:
Rendo 2025-11-06 06:27:45 +05:00
commit 06274cd5a5
3 changed files with 8 additions and 7 deletions

View file

@ -3,7 +3,7 @@ use crate::formula::node::Node;
pub mod node; pub mod node;
pub struct Formula { pub struct Formula {
root: node::Node<F>, root: node::Node,
} }
impl Formula { impl Formula {

View file

@ -1,3 +0,0 @@
pub trait Function {
fn map(x: f64) -> f64;
}

View file

@ -1,6 +1,5 @@
use crate::formula::node::graph_constructor::GraphBuilder; use crate::formula::node::graph_constructor::GraphBuilder;
mod function;
mod graph_constructor; mod graph_constructor;
pub struct Node { pub struct Node {
@ -20,8 +19,13 @@ impl Node {
} }
pub fn get_value(&self) -> f64 { pub fn get_value(&self) -> f64 {
if self.children.len() == 0 { if self.children.len() == 0 {
0f64 return (self.function)(vec![0f64]);
} }
for node in self.children {} let mut inputs: Vec<f64> = vec![];
for node in &self.children {
inputs.push(node.get_value());
}
return (self.function)(inputs);
} }
} }