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
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package=criterion | |
import Criterion.Main | |
import Data.Char (intToDigit) | |
import Data.List (intercalate) | |
type Expression = [Term] | |
type Term = [Factor] | |
type Factor = [Digit] |
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
-- Semigroups and monoids | |
-- On Maybe: | |
-- Nothing disappears, left wins | |
instance Monoid (Maybe a) where | |
mempty = Nothing | |
Nothing `mappend` y = y | |
x `mappend` _ = x |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-5.5 --install-ghc runghc | |
-- Pizza Hut solution for Pi Day problem 1 | |
-- http://blog.pizzahut.com/flavor-news/national-pi-day-math-contest-problems-are-here-2/ | |
import Data.List (permutations) | |
main = putStrLn $ head solutions |
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
module SchemeParser where | |
import Text.Parsec | |
import Text.Parsec.String | |
(<>) :: Parser [a] -> Parser [a] -> Parser [a] | |
p1 <> p2 = do r1 <- p1; r2 <- p2; return (r1 ++ r2) | |
one :: Parser a -> Parser [a] | |
one = fmap (:[]) |
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
import Control.Monad | |
import Data.Char | |
import Text.Parsec | |
import Text.Parsec.String | |
data SExpr = | |
SSym { getSym :: String } | | |
SInt !Integer | | |
SBool !Bool | | |
SList [SExpr] | |
NewerOlder