Skip to content
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

Add WIP calc. #2

Merged
merged 5 commits into from
Mar 8, 2016
Merged

Add WIP calc. #2

merged 5 commits into from
Mar 8, 2016

Conversation

LazyOxen
Copy link
Contributor

@LazyOxen LazyOxen commented Mar 4, 2016

Still a few TODOs. The main ones would be converting the functions to use iterators if possible, as well as getting exponentiation to work, the compiler kept barking at me regarding powf, and I wasn't sure how to fix it.

@@ -0,0 +1,418 @@
use std::prelude::v1::*;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary.

@ticki
Copy link
Contributor

ticki commented Mar 4, 2016

Cool stuff! I just added a few nit-picky comments.

@jackpot51
Copy link
Member

Ticki is asleep, so hoping that the issues were taken care of, I will merge. Thanks!

jackpot51 added a commit that referenced this pull request Mar 8, 2016
@jackpot51 jackpot51 merged commit e0bfad2 into redox-os:master Mar 8, 2016
@LazyOxen
Copy link
Contributor Author

LazyOxen commented Mar 9, 2016

Thanks! Functionality-wise it should be fine. Exponentiation is commented out until powf is implemented in redox.

let mut stderr = io::stderr();
if args.len() > 1 {
let input: Vec<String> = args.skip(1).collect();
println!("{}", eval(&input.join("")));
Copy link
Contributor

Choose a reason for hiding this comment

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

You missed this one.

@ticki
Copy link
Contributor

ticki commented Mar 9, 2016

Great work, @LazyOxen!

let input_length = chars.len();
let mut current_pos = 0;
while current_pos < input_length {
let c : char = chars[current_pos];
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for denoting the type here.

match tokenize(input).and_then(parse) {
Ok(s) => s,
Err(e) => match e {
ParseError::InvalidNumber(s) => ["Invalid number: ", s.as_str() ].join(""),
Copy link
Contributor

Choose a reason for hiding this comment

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

concat() is slightly faster than join("").

@ticki
Copy link
Contributor

ticki commented Mar 9, 2016

Just read the code. It is extremely well-written and very readable. 👍

@LazyOxen
Copy link
Contributor Author

Thanks, been having some internet issues lately, hopefully I'll have better luck this weekend so I can update the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants