Skip to content

Commit fc30f5f

Browse files
committed
add conversion from , to .
1 parent 0c34808 commit fc30f5f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ pub fn reverse_polish_parsing(infix_input: &String)->Result<Vec<String>>{
112112
if index > 0 && !infix_as_chars[index - 1].is_digit(10) || index == 0{
113113
next_output_value_num.push('0');
114114
}
115-
116-
next_output_value_num.push(*chr);
115+
//we want to support both . and , but , is not supprted so we have to convert it to .
116+
if *chr == ',' {
117+
next_output_value_num.push('.');
118+
}
119+
else {
120+
next_output_value_num.push(*chr);
121+
}
117122

118123
}
119124
else if chr.is_alphabetic() {

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::time::Instant;
33

44
fn main(){
55
let before = Instant::now();
6-
let value: Vec<String> = match lib::reverse_polish_parsing(&".8+.7+((2^2)*3-1)-(2^2)+2-sqrt(5*7+3)".to_string()){
6+
let value: Vec<String> = match lib::reverse_polish_parsing(&".8+.7+7,7+((2^2)*3-1)-(2^2)+2-sqrt(5*7+3)".to_string()){
77
Ok(a) => a,
88
Err(e) => {println!("Error {:?}", e); return;},
99
};

0 commit comments

Comments
 (0)