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
In http://github.com/johanlindberg/langgeeks/commit/3e6249fcd36be6685cce2a6936da8dd2471cbd51 | |
you have: | |
> process :: String -> (Char, [String]) | |
> process filename = do contents <- readFile filename | |
> return (getPlayer contents, getBoard contents) | |
It looks like you want to read the file and extract the player and board to pass this on to | |
another function. All that is missing here is the IO in the type signature. |
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 Main where | |
import System.Random | |
import Data.Function | |
processGuess :: Int -> IO () -> IO () | |
processGuess answer cont = do | |
n <- getLine | |
case compare (read n) answer of | |
EQ -> putStrLn "Awesome!!!!" |
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
-- | This program benchmarks different versions of the counting function for | |
-- the Rope Intranet problem for Google Code Jam | |
-- http://code.google.com/codejam/contest/dashboard?c=619102#. | |
-- | |
-- To compile: | |
-- >>> ghc -O2 --make bench.hs | |
-- | |
-- To run (Windows): | |
-- >>> Bench |
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 Main where | |
makeAGuess :: Int -> Int -> Int | |
makeAGuess i j = (i + j) `div` 2 | |
guess :: Int -> Int -> IO () | |
guess i j = do | |
let x = makeAGuess i j | |
putStrLn (show 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
module Main where | |
import Data.Char | |
import Data.List | |
data Guess | |
= Guess Int Guess Guess | |
| GiveUp | |
| Done |
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 Expressions where | |
import Data.Maybe | |
import Text.Printf | |
import Control.Applicative | |
data Expr = Term Int | Op Operator Expr Expr | Var String | |
deriving (Show, Eq) | |
data Operator = Sum | Mult | Sub | Div |
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 Data.Maybe | |
import Text.Printf | |
import Data.Char | |
import Control.Monad | |
data Expr = Term Int | Op Operator Expr Expr | Var String | |
deriving (Show, Eq) | |
data Operator = Sum | Mult | Sub | Div | |
deriving (Show, Eq) |
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 Main where | |
import Control.Arrow | |
import Data.Array | |
import Data.Char | |
import Data.Bits | |
import Data.Function | |
import Data.List | |
import Data.Maybe | |
type Bark = Array (Int, Int) Bool |
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 Main where | |
import Text.Printf | |
profit :: Integer -> Integer -> [Integer] -> Integer | |
profit cap rides groups | |
| sum groups <= cap = rides * sum groups | |
| otherwise = profit' cap rides (cycle groups) | |
where |
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
-- This program solves the Theme Park Google CodeJam problem at | |
-- http://code.google.com/codejam/contest/dashboard?c=433101#s=p2 | |
-- | |
-- I've tried to make the code clear whilst employing a selection of Haskell library | |
-- functions and idioms. I've also gone for efficiency, probably over optimizing in | |
-- places in order to demonstrate some techniques. | |
module Main where | |
import Data.List |
OlderNewer