This commit is contained in:
Jasper Ras 2026-01-15 09:09:24 +01:00
parent eb9773627e
commit 10b29ad9cb
14 changed files with 164 additions and 0 deletions

22
ch8/ch10/pig_latin.rs Normal file
View file

@ -0,0 +1,22 @@
fn main() {
let vowels = vec!['a', 'e', 'i', 'o', 'u'];
let words = vec!["flow", "fool", "dick", "cock", "sex", "ape", "eel", "apple", "addicted", "ore"];
for word in words {
let c = word.chars().next().unwrap();
let mut adj = format!("-{c}ay");
for vowel in vowels.iter() {
if c != *vowel {
continue;
}
adj = String::from("-hay");
break;
}
let w = String::from(word) + &adj;
println!("{w}");
}
}