Created
July 18, 2014 19:18
-
-
Save josue/cf24df20f047ae3a6c37 to your computer and use it in GitHub Desktop.
Experimenting with Haskell - simple script that reads name, validates with functions and writes output to file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Environment | |
import Data.Char | |
main = promptNameAndSave | |
matchesName s = if (map toUpper s) == "JOSUE" then True else False | |
checkIfBeast str = if matchesName str then "a BEAST !" else "normal." | |
finalMessage h i = "Thanks " ++ h ++ ", you are " ++ i | |
addToFile s = writeFile "is_beast.out" (s ++ "\n") | |
promptNameAndSave = do | |
putStrLn "What is your name?" | |
name <- getLine | |
let message = finalMessage name (checkIfBeast name) | |
putStrLn $ "\n" ++ message | |
addToFile message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run in command-line as: