-
Notifications
You must be signed in to change notification settings - Fork 0
Skeloton #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Skeloton #16
Conversation
[dependencies] | ||
lazy_static = "1.4.0" | ||
bigdecimal = "0.3.0" | ||
num-bigint = "0.4.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove that
@@ -1,7 +1,13 @@ | |||
use std::fmt::{Display, Formatter}; | |||
#![feature(map_first_last)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also remove that
// } | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] | ||
pub enum Values { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible introduce a reference to LocalizedSyntaxNode/Values and indicating how it got introduced
} | ||
} | ||
|
||
impl Display for Values { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a biit of rework. 2x will displayed as 0 + 2x
|
||
//const two : BigDecimal = BigDecimal::from(2); | ||
|
||
fn exponantiate(mut x: BigDecimal, mut y: BigDecimal) -> BigDecimal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need figure smthng out for rational powers
Self::entry_adder(a, b, BigDecimal::add_assign) | ||
}), | ||
), | ||
(Values::Sum(cx, x), Values::Product(cy, y)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this arm needs rework
server/src/ast/parser/tests/mod.rs
Outdated
} | ||
|
||
#[test] | ||
fn add_two_variables_and_convert_to_values() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least the tests are easier to write
assert_eq!(expected,result_text) | ||
} | ||
#[test] | ||
fn cube_of_sum() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test fails atm smthing funny going on with exponentiation
server/src/ast/mod.rs
Outdated
fn square_of_diff() { | ||
let result : Values = parse("(x+y)*(x-y)".to_string()).unwrap().pop().unwrap().into(); | ||
|
||
let expected = "( 0 + 0 * ( 1 * x ^ 1 * y ^ 1 ) + 1 * (x ^ 2) + -1 * (y ^ 2) )"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know.. but we can work on cosmetics later
} | ||
|
||
impl Values { | ||
// fn entry_adder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should come back. i had a brain fart
// map | ||
// } | ||
|
||
fn entry_adder<F>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is unnecessarily general. i had a brain fart. commented out one should work
server/src/ast/mod.rs
Outdated
map | ||
} | ||
|
||
fn const_folder<F>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont need this any more
I think I'm against hardcoding the rules. I would rather implement a generic rules engine that you feed the rules. |
No description provided.