Skip to content

Instantly share code, notes, and snippets.

View jhickner's full-sized avatar

Jason Hickner jhickner

  • Formation / VaryWell / Kite & Lightning
  • Seattle
View GitHub Profile
-- http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html
data U x = U [x] x [x]
right (U a b (c:cs)) = U (b:a) c cs
left (U (a:as) b c) = U as a (b:c)
instance Functor U where
fmap f (U a b c) = U (map f a) (f b) (map f c)
import Data.Char
strong = and . sequence conditions
where conditions = [ (>14) . length
, any isUpper
, any isLower
, any isDigit
]
{-
import Data.Array
import Data.Maybe
data Piece = X | O | Empty deriving (Eq)
instance Show Piece where
show X = "X"
show O = "O"
show Empty = " "
import Data.List
data Dir = N | S | E | W deriving (Eq, Show)
type Coord = (Int, Int)
(|+|) (x,y) (x',y') = (x+x',y+y')
infixl 6 |+|
toDelta d = case d of
N -> (0, -1)
import Control.Monad
import Control.Applicative
import Control.Proxy
import System.IO
import Prelude hiding (Left, Right)
data Input = Up | Down | Left | Right | Invalid deriving Show
toInput :: Char -> Input
toInput c = case c of
{-# LANGUAGE RecordWildCards #-}
import Data.Monoid
data SalaryConfig = SalaryConfig
{ sAllowances :: Bool
, sBonus :: Bool
, sTax :: Bool
, sSurcharge :: Bool
}
import Data.Ord (comparing)
import Data.Function (on)
import Data.List (groupBy)
type Point = (Int, Int)
points :: [Point]
points = [ (0, 1)
, (0, 2)
, (0, 2)
import Control.Monad
import Control.Applicative
import Control.Proxy
import qualified Control.Proxy.Trans.State as S
import System.IO
import Prelude hiding (Left, Right)
type Pos = (Int, Int)
data Input = Up | Down | Left | Right | Invalid deriving Show
@jhickner
jhickner / reddit.hs
Last active December 16, 2015 04:49
{-# LANGUAGE TemplateHaskell, OverloadedStrings, FlexibleInstances, TypeSynonymInstances #-}
import Network.URI (URI, parseURI)
import Network.HTTP
import Control.Applicative
import Data.Aeson
import qualified Data.ByteString.Lazy as BL
import Data.Maybe (fromJust)
redditURL = fromJust . parseURI $ "http://www.reddit.com/by_id/t3_1c578w.json"
-- adapted from the pipes-network package
-- http://hackage.haskell.org/package/pipes-network
module TCP (
-- * Server side
-- $server-side
serve,
serveFork,
-- ** Listening
listen,