Last active
November 10, 2017 14:43
-
-
Save mclosson/12e8fca8e0eaffe6354a9ee8e5568ba8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::*; | |
fn main() { | |
loop{ | |
let mut l = String::new(); | |
let mut a = 0; | |
print!(">> "); | |
stdout().flush().unwrap(); | |
stdin().read_line(&mut l).unwrap(); | |
for c in l.chars() { | |
match c { | |
'i'|'x' => a += 1, | |
'd' => a -= 1, | |
's'|'k' => a *= a, | |
'o' => println!("{}", a), | |
_ => {} | |
} | |
match a { | |
-1|256 => a = 0, | |
_ => {} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::*;fn main(){loop{let mut l=String::new();let mut a=0;print!(">> ");stdout().flush().unwrap();stdin().read_line(&mut l).unwrap();for c in l.chars(){match c{'i'|'x'=>a+= 1,'d'=>a-=1,'s'|'k'=>a*= a,'o'=>println!("{}",a),_=>{}}match a{-1|256=>a=0,_=>{}}}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Deadfish interpreter written in Rust.
266 characters for code golf.
https://codegolf.stackexchange.com/questions/16124/write-an-interactive-deadfish-interpreter