This file contains hidden or 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 qualified Data.Map as Map | |
-- record | |
-- data Person = Person {firstName :: String, | |
-- lastName :: String, | |
-- age :: Int, | |
-- height :: Float, | |
-- phoneNumber :: String, | |
-- flavor :: String} deriving(Show) | |
-- guy = Person "Buddy" "Finklestein" 43 184.2 "562-2928" "Chocolate" |
This file contains hidden or 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
main :: IO () | |
main = do | |
putStrLn "What's your name?" | |
name <- getLine | |
putStrLn $ "Your name is " ++ name | |
-- nameTag = "Hello, my name is " ++ getLine Typing Error |
This file contains hidden or 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 Data.Char | |
main :: IO () | |
main = do | |
putStrLn "What's your first name?" | |
firstName <- getLine | |
putStrLn "What's your last name?" | |
lastName <- getLine | |
let bigFirstName = map toUpper firstName | |
bigLastName = map toUpper lastName |
This file contains hidden or 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
main :: IO () | |
main = do | |
return () | |
return "HAHAHA" | |
line <- getLine | |
return "BLAH BLAH " | |
return 4 | |
putStrLn line |
This file contains hidden or 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
main :: IO () | |
main = do | |
a <- return "hell" | |
b <- return "yeah!" | |
putStrLn $ a ++ " " ++ b | |
-- main = do | |
-- let a = "hell" | |
-- b = "yeah" | |
-- putStrLn $ a ++ " " ++ b |
This file contains hidden or 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 Control.Monad | |
import Data.Char | |
main :: IO () | |
-- putStr | |
-- main = do | |
-- putStr "Hey, " | |
-- putStr "I'm " | |
-- putStr "Andy!" | |
-- putChar |
This file contains hidden or 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 Control.Monad | |
import Data.Char | |
main :: IO () | |
-- putStr | |
-- main = do | |
-- putStr "Hey, " | |
-- putStr "I'm " | |
-- putStr "Andy!" | |
-- putChar |
This file contains hidden or 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 Control.Monad | |
import Data.Char | |
main :: IO () | |
main = forever $ do | |
l <- getContents | |
putStrLn $ map toUpper l |
This file contains hidden or 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
main :: IO () | |
main = do | |
contents <- getContents | |
putStr $ shortLinesOnly contents | |
shortLinesOnly :: String -> String | |
shortLinesOnly = unlines . filter (\ line -> length line < 10) . lines | |
-- lines :: String -> [String] | |
-- lines "aaa\nbbb\nccc" => ["aaa","bbb","ccc"] |
This file contains hidden or 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
main :: IO () | |
main = interact shortLinesOnly | |
shortLinesOnly :: String -> String | |
shortLinesOnly = unlines . filter (\ s -> length s < 10) . lines |