Last active
July 1, 2019 21:52
-
-
Save nobsun/188d5e6370ea0cc69c98 to your computer and use it in GitHub Desktop.
Haskellプログラミングのコツのようなもの ref: https://qiita.com/nobsun/items/ed33c22203734e706e9b
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
main = interact gonyo |
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
gonyo :: String -> String | |
gonyo = unlines . munyo . lines |
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
f :: Line -> Line | |
f = take 1 . drop 4 |
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
munyo :: [Line] -> [Line] | |
munyo = map (take 1 . drop 4) |
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
main :: IO () | |
main = interact (linesWrap onlyFifthChars) | |
type Line = String | |
onlyFifthChars :: [Line] -> [Line] | |
onlyFifthChars = map (take 1 . drop 4) | |
-- utility | |
linesWrap :: ([Line] -> [Line]) -> (String -> String) | |
linesWrap f = unlines . f . lines |
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
gonyo :: String -> String | |
gonyo = linesWrap munyo | |
type Line = String | |
linesWrap :: ([Line] -> [Line]) -> (String -> String) | |
linesWrap f = unlines . f . lines |
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
main :: IO () | |
main = interact (linesWrap munyo) | |
linesWrap :: ([Line] -> [Line]) -> (String -> String) | |
linesWrap f = unlines . f . lines |
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
p :: Line -> Bool | |
p = (40 >=) . length |
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
munyo :: [Line] -> [Line] | |
munyo = filter ((40 >=) . length) |
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
f :: Line -> Line | |
f = reverse . take 10 . reverse |
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
munyo :: [Line] -> [Line] | |
munyo = map (reverse . take 10 . reverse) |
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
main :: IO () | |
main = interact (linesWrap lastTenChars) | |
type Line = String | |
lastTenChars :: [Line] -> [Line] | |
lastTenChars = map (reverse . take 10 . reverse) | |
-- utility | |
linesWrap :: ([Line] -> [Line]) -> (String -> String) | |
linesWrap f = unlines . f . lines |
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
main :: IO () | |
main = interact (linesWrap shortLines) | |
type Line = String | |
shortLines :: [Line] -> [Line] | |
shortLines = filter ((40 >=) . length) | |
-- utility | |
linesWrap :: ([Line] -> [Line]) -> (String -> String) | |
linesWrap f = unlines . f . lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment