The Name Game: Difference between revisions

(→‎{{header|UNIX Shell}}: Add implementation.)
Line 1,846:
This implements the required rules and also attempts to handle names that start with consonant clusters.
 
<lang sh>namegame()#!/usr/bin/env {bash
namegame() {
local name=$1 b=b f=f m=m
local rhyme=${name#?[^AaEeIiOoUu]}
while [[ $rhyme == [^aeiouyAaEeIiOoUuYy]* ]]; do
rhyme=${rhyme#?}
done
if [[ "$rhyme" == [AEIOU]* ]]; then
rhyme=$(tr A-Z a-z <<<"$rhyme")
fi
if [[ $name == [Bb]* ]]; then
b=
Line 1,866 ⟶ 1,870:
printf '%s!\n' "$name"
}
 
 
for name in Gary Earl Billy Felix Mark Frank; do
Line 1,878 ⟶ 1,883:
Gary!
 
Earl, Earl, bo-barlbearl
Banana-fana fo-farlfearl
Fee-fi-mo-marlmearl
Earl!
 
Line 1,901 ⟶ 1,906:
Banana-fana fo-ank
Fee-fi-mo-mank
Frank!</pre>
 
</pre>
 
=={{header|VBA}}==
1,481

edits