The Name Game: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
Added Go
m finshed haskell source
Line 322:
 
=={{header|Haskell}}==
{{incomplete|haskell|B, F, M special rules are not implemented.}}
<lang Haskell>
-- The Name Game, Ethan Riley, 22nd May 2018
Line 336 ⟶ 335:
| otherwise = False
where char = toUpper c
 
isSpecial :: Char -> Bool
isSpecial c
| char == 'B' = True
| char == 'F' = True
| char == 'M' = True
| otherwise = False
where char = toUpper c
 
shorten :: String -> String
Line 341 ⟶ 348:
| isVowel $ head name = map toLower name
| otherwise = map toLower $ tail name
 
line :: String -> Char -> String -> String
line prefix letter name
| letter == char = prefix ++ shorten name ++ "\n"
| otherwise = prefix ++ letter:[] ++ shorten name ++ "\n"
where char = toLower $ head name
 
theNameGame :: String -> String
theNameGame name =
line (name ++ ", " ++ name ++ ", bo-b") ++ shorten'b' name ++ "\n" ++
line "Banana-fana fo-f" ++ shorten'f' name ++ "\n" ++
line "Fee-fi-mo-m" ++ shorten'm' name ++ "\n" ++
name ++ "!\n"
main = do
mapM_ (putStrLn . theNameGame) ["Gary", "Earl", "Billy", "Felix", "Mike", "Steve"]
</lang>
Line 364 ⟶ 377:
Earl!
 
Billy, Billy, bo-billyilly
Banana-fana fo-filly
Fee-fi-mo-milly
Line 370 ⟶ 383:
 
Felix, Felix, bo-belix
Banana-fana fo-felixelix
Fee-fi-mo-melix
Felix!
Line 376 ⟶ 389:
Mike, Mike, bo-bike
Banana-fana fo-fike
Fee-fi-mo-mikeike
Mike!