-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomposition.hs
40 lines (29 loc) · 936 Bytes
/
composition.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Composition where
import Data.Char
import Data.List (sort)
import qualified Data.Char as C
main = do
poem <- readFile "bjerke.txt"
putStr poem
putStr "\n"
putStr . process $ poem
putStr $ (replicate 55 '-') ++ "\n"
putStr . indentEachLine $ poem
process t = unlines (sort (lines t))
process' t = (unlines . sort . lines) t
process'' = unlines . sort . lines
sortLines = unlines . sort . lines
reverseLines = unlines . reverse . lines
firstTwoLines = unlines . take 2 . lines
byLines f = unlines . f . lines
sortLines' = byLines sort
reverseLines' = byLines reverse
firstTwoLines' = byLines (take 2)
indent :: String -> String
indent s = " " ++ s
indentEachLine :: String -> String
indentEachLine = byLines (map indent)
eachLine :: (String -> String) -> String -> String
eachLine f = unlines . map f . lines
indentEachLine' :: String -> String
indentEachLine' = eachLine indent