Skip to content

Instantly share code, notes, and snippets.

@mclosson
Last active November 10, 2017 14:43
Show Gist options
  • Save mclosson/12e8fca8e0eaffe6354a9ee8e5568ba8 to your computer and use it in GitHub Desktop.
Save mclosson/12e8fca8e0eaffe6354a9ee8e5568ba8 to your computer and use it in GitHub Desktop.
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,
_ => {}
}
}
}
}
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,_=>{}}}}}
@mclosson
Copy link
Author

Deadfish interpreter written in Rust.
266 characters for code golf.
https://codegolf.stackexchange.com/questions/16124/write-an-interactive-deadfish-interpreter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment