Created
January 15, 2014 07:09
-
-
Save nnabeyang/8432085 to your computer and use it in GitHub Desktop.
IFPHの12章のプログラムの動かし方 ref: http://qiita.com/nnabeyang/items/f01103bc4487a5cc202c
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
| ghci> :l Examples | |
| ghci> ex6 |
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 | |
| > instance Functor Parser where | |
| > -- map f p = MkP g | |
| > fmap f p = MkP g | |
| > where g s = [(f x, s') | (x,s') <- papply p s] | |
| > alphanum :: Parser Char | |
| > -- alphanum = sat isAlphaum | |
| > alphanum = sat isAlphaNum |
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
| > partitions :: Int -> [a] -> [[[a]]] | |
| > partitions 0 [] = [[]] | |
| > partitions n [] = [] | |
| > partitions 0 _ = [] | |
| > partitions n (x:xs) = [[x]:yss | yss <- partitions (n-1) xs] ++ | |
| > [(x:ys):yss | ys:yss <- partitions n xs] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment