The Name Game: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
|||
Line 946: | Line 946: | ||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
⚫ | |||
Unlike most other implementations presented in this page, this one actually handles consonant clusters, just like the original song. |
|||
proc verse x$ . . |
|||
⚫ | |||
⚫ | |||
y$ = substr x$ 2 99 |
|||
proc toLowercase string$ . result$ . |
|||
if strpos "AEIOU" x1$ <> 0 |
|||
for i = 1 to len string$ |
|||
h$ = strchar (strcode x1$ + 32) |
|||
y$ = h$ & y$ |
|||
⚫ | |||
. |
|||
result$ &= strchar code |
|||
. |
. |
||
⚫ | |||
. |
|||
⚫ | |||
proc findInStrArray array$[] item$ . index . |
|||
m$ = "m" & y$ |
|||
if x1$ = "B" |
|||
b$ = y$ |
|||
elif x1$ = "F" |
|||
f$ = y$ |
|||
⚫ | |||
⚫ | |||
. |
. |
||
⚫ | |||
index = 0 |
|||
⚫ | |||
. |
|||
⚫ | |||
# This version actually handles consonant clusters |
|||
⚫ | |||
name$ = input |
|||
toLowercase name$ lowerName$ |
|||
vowels$[] = [ "a" "e" "i" "o" "u" ] |
|||
for i = 1 to len lowerName$ |
|||
⚫ | |||
findInStrArray vowels$[] letter$ index |
|||
if index <> 0 |
|||
truncName1$ = substr lowerName$ i len lowerName$ |
|||
break 1 |
|||
. |
|||
truncName1$ = "" |
|||
. |
|||
firstLetter$ = substr lowerName$ 1 1 |
|||
if firstLetter$ <> "b" |
|||
⚫ | |||
. |
|||
if firstLetter$ <> "f" |
|||
⚫ | |||
. |
|||
if firstLetter$ <> "m" |
|||
⚫ | |||
. |
|||
if b$ = "" or f$ = "" or m$ = "" |
|||
truncName2$ = substr lowerName$ 2 len lowerName$ |
|||
. |
|||
# Determine the appropriate name for each line |
|||
if b$ = "" |
|||
bName$ = truncName2$ |
|||
else |
|||
bName$ = truncName1$ |
|||
. |
|||
if f$ = "" |
|||
fName$ = truncName2$ |
|||
else |
|||
fName$ = truncName1$ |
|||
. |
. |
||
for n$ in [ "Gary" "Earl" "Billy" "Felix" "Mary" ] |
|||
if m$ = "" |
|||
verse n$ |
|||
print "" |
|||
else |
|||
mName$ = truncName1$ |
|||
. |
. |
||
# Print the song |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{in}} |
|||
<pre> |
|||
Gary |
|||
Earl |
|||
Billy |
|||
Shirley |
|||
</pre> |
|||
{{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! |
|||
Shirley, Shirley, bo-birley |
|||
Banana-fana fo-firley |
|||
Fee-fi-mo-mirley |
|||
Shirley! |
|||
</pre> |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |