-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
@@ -0,0 +1,418 @@ | |||
use std::prelude::v1::*; |
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 not necessary.
Cool stuff! I just added a few nit-picky comments. |
Ticki is asleep, so hoping that the issues were taken care of, I will merge. Thanks! |
Thanks! Functionality-wise it should be fine. Exponentiation is commented out until |
let mut stderr = io::stderr(); | ||
if args.len() > 1 { | ||
let input: Vec<String> = args.skip(1).collect(); | ||
println!("{}", eval(&input.join(""))); |
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.
You missed this one.
Great work, @LazyOxen! |
let input_length = chars.len(); | ||
let mut current_pos = 0; | ||
while current_pos < input_length { | ||
let c : char = chars[current_pos]; |
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.
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(""), |
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.
concat()
is slightly faster than join("")
.
Just read the code. It is extremely well-written and very readable. 👍 |
Thanks, been having some internet issues lately, hopefully I'll have better luck this weekend so I can update the code |
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.