Skip to content

Conversation

ekinimo
Copy link
Collaborator

@ekinimo ekinimo commented Jun 24, 2022

No description provided.

[dependencies]
lazy_static = "1.4.0"
bigdecimal = "0.3.0"
num-bigint = "0.4.3"
Copy link
Collaborator Author

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)]
Copy link
Collaborator Author

@ekinimo ekinimo Jun 24, 2022

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 {
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

@ekinimo ekinimo Jun 24, 2022

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 {
Copy link
Collaborator Author

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))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this arm needs rework

}

#[test]
fn add_two_variables_and_convert_to_values() {
Copy link
Collaborator Author

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() {
Copy link
Collaborator Author

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

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) )";
Copy link
Collaborator Author

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(
Copy link
Collaborator Author

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>(
Copy link
Collaborator Author

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

map
}

fn const_folder<F>(
Copy link
Collaborator Author

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

@pubrrr
Copy link
Owner

pubrrr commented Sep 22, 2022

I think I'm against hardcoding the rules. I would rather implement a generic rules engine that you feed the rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants