Skip to content

Instantly share code, notes, and snippets.

@Tomren3000
Created June 3, 2015 18:03
Show Gist options
  • Save Tomren3000/9abf8285f10923ab3af3 to your computer and use it in GitHub Desktop.
Save Tomren3000/9abf8285f10923ab3af3 to your computer and use it in GitHub Desktop.
printLines.hs
import Data.Char
navne :: [String]
navne = ["Morten", "Thomas", "Trine"]
buildString :: String -> [String] -> String
buildString a [x] = a ++ x ++ "\n"
buildString a xs = buildString (a ++ head xs ++ "\n") (tail xs)
buildString' :: String -> [String] -> String
buildString' a xs = if length xs == 1
then a ++ head xs ++ "\n"
else buildString' (a ++ head xs ++ "\n") (tail xs)
folder :: [String] -> IO ()
folder xs = putStr $ foldl (\result name -> result ++ name ++ "\n") "foo" xs
mapper = mapM_ putStrLn navne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment