Skip to content

Commit 91e38a5

Browse files
author
梶塚太智
committed
Update main.rs
Implemented command `only-number`, it judges string include only number
1 parent d645307 commit 91e38a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,14 @@ impl Executor {
919919
}
920920
}
921921

922+
// Is string include only number
923+
"only-number" => {
924+
match self.pop_stack().get_string().trim().parse::<f64>() {
925+
Ok(_) => self.stack.push(Type::Bool(true)),
926+
Err(_) => self.stack.push(Type::Bool(false))
927+
}
928+
}
929+
922930
// Get memory information
923931
"mem" => {
924932
let mut list: Vec<Type> = Vec::new();

0 commit comments

Comments
 (0)