-
Notifications
You must be signed in to change notification settings - Fork 0
/
sonat.hs
36 lines (31 loc) · 1.36 KB
/
sonat.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
-- sonat.hs
import System.IO
import Data.List
import Data.Char
main = do
writeFile output text
putStrLn (['L','o','a','d',' ','a','n','d',' ','r','u','n',' '] ++ output)
pieces = ["-- sonat.hs",
"-- tulay.hs",
"",
"import System.IO",
"import Data.List",
"import Data.Char",
"",
"main = do",
" writeFile output text",
" putStrLn (['L','o','a','d',' ','a','n','d',' ','r','u','n',' '] ++ output)",
"",
"pieces = [",
"",
"output = drop 3 (pieces !! 1)",
"",
"text = lines' (drop 1 (take 12 pieces)) ++ (punctuate . swapFirstTwo) pieces ++ [']', chr 10] ++ lines' (drop 12 pieces)",
" where lines' = intercalate [chr 10]",
" swapFirstTwo (x0:x1:xs) = x1:x0:xs",
" punctuate = intercalate ([',',chr 10] ++ replicate 10 ' ') . map (([chr 34] ++).( ++ [chr 34]))"]
output = drop 3 (pieces !! 1)
text = lines' (drop 1 (take 12 pieces)) ++ (punctuate . swapFirstTwo) pieces ++ [']', chr 10] ++ lines' (drop 12 pieces)
where lines' = intercalate [chr 10]
swapFirstTwo (x0:x1:xs) = x1:x0:xs
punctuate = intercalate ([',',chr 10] ++ replicate 10 ' ') . map (([chr 34] ++).( ++ [chr 34]))