Skip to content

Instantly share code, notes, and snippets.

@nnabeyang
Created January 15, 2014 07:09
Show Gist options
  • Select an option

  • Save nnabeyang/8432085 to your computer and use it in GitHub Desktop.

Select an option

Save nnabeyang/8432085 to your computer and use it in GitHub Desktop.
IFPHの12章のプログラムの動かし方 ref: http://qiita.com/nnabeyang/items/f01103bc4487a5cc202c
ghci> :l Examples
ghci> ex6
> 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
> 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