Created
May 13, 2017 05:06
-
-
Save harlanhaskins/1124877c59786a081690bd93fd0e1571 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::env; | |
fn print_spongebob(vals: &[String]) { | |
let statement = vals.join(" "); | |
let mut lower = true; | |
for c in statement.chars() { | |
let new_c = if lower { c.to_lowercase().next() } | |
else { c.to_uppercase().next() }; | |
if let Some(c) = new_c { | |
print!("{}", c); | |
} | |
lower = !lower; | |
} | |
print!("\n"); | |
} | |
fn main() { | |
let args: Vec<_> = env::args().collect(); | |
if let Some((_, tail)) = args.split_first() { | |
print_spongebob(tail); | |
} else { | |
println!("usage: spongebobify [statement...]") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haskell version: