ch08
This commit is contained in:
parent
eb9773627e
commit
10b29ad9cb
14 changed files with 164 additions and 0 deletions
22
ch8/ch10/pig_latin.rs
Normal file
22
ch8/ch10/pig_latin.rs
Normal 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}");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue