The Name Game: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added syntax colouring the hard way |
|||
Line 1,588:
print_verse(n)
end</lang>
=={{header|Nim}}==
<lang Nim>import strutils
const
StdFmt = "$1, $1, bo-b$2\nBanana-fana fo-f$2\nFee-fi-mo-m$2\n$1!"
WovelFmt = "$1, $1, bo-b$2\nBanana-fana fo-f$2\nFee-fi-mo-m$2\n$1!"
BFmt = "$1, $1, bo-$2\nBanana-fana fo-f$2\nFee-fi-mo-m$2\n$1!"
FFmt = "$1, $1, bo-b$2\nBanana-fana fo-$2\nFee-fi-mo-m$2\n$1!"
MFmt = "$1, $1, bo-b$2\nBanana-fana fo-f$2\nFee-fi-mo-$2\n$1!"
proc lyrics(name: string): string =
let tail = name[1..^1]
result = case name[0].toUpperAscii
of 'A', 'E', 'I', 'O', 'U', 'Y':
WovelFmt.format(name, name.toLowerAscii)
of 'B':
BFmt.format(name, tail)
of 'F':
FFmt.format(name, tail)
of 'M':
MFmt.format(name, tail)
else:
StdFmt.format(name, tail)
result = result.capitalizeAscii()
for name in ["Gary", "Earl", "Billy", "Felix", "Mary"]:
echo name.lyrics()
echo()</lang>
{{out}}
<pre>Gary, Gary, bo-bary
Banana-fana fo-fary
Fee-fi-mo-mary
Gary!
Earl, Earl, bo-bearl
Banana-fana fo-fearl
Fee-fi-mo-mearl
Earl!
Billy, Billy, bo-illy
Banana-fana fo-filly
Fee-fi-mo-milly
Billy!
Felix, Felix, bo-belix
Banana-fana fo-elix
Fee-fi-mo-melix
Felix!
Mary, Mary, bo-bary
Banana-fana fo-fary
Fee-fi-mo-ary
Mary!</pre>
=={{header|Perl}}==
|