Skip to content

Instantly share code, notes, and snippets.

def prefix_function(s):
result = len(s) * [0]
for (i, c) in enumerate(s):
if i == 0:
continue
guess = result[i - 1]
while True:
module Dfs where
import Control.Monad.State
import Data.IntMap (IntMap)
import Data.IntSet (IntSet)
import Data.Maybe (fromMaybe)
import qualified Data.IntMap as IntMap
import qualified Data.IntSet as IntSet
type Vertex = Int
@ddrone
ddrone / Lecture1.hs
Created June 26, 2015 12:18
Raw notes from Patterns of Functional Programming course from Midlands Graduate School 2015
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS -Wall -fno-warn-orphans #-}
module Lecture1 where
import Data.List (partition)
@ddrone
ddrone / Main.hs
Created December 6, 2014 16:11
ProjectEuler score calculator
module Main where
import Control.Monad
import Data.Functor ((<$>))
import Text.HTML.TagSoup
extractData tags =
case dropWhile (~/= "<td class=problem_solved>") tags of
[] -> []
ls@(hd : tl) -> (take 8 ls : extractData tl)
{-# LANGUAGE TypeOperators #-}
module Lecture6 where
import Control.Applicative
import Control.Monad.State hiding (sequence)
import Data.Char (isSpace)
import Data.Monoid hiding (getAll)
import Prelude hiding (sequence)
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Typelevel where
import Prelude hiding (sum)
-- type-level natural numbers
data Zero = Zero
module Indexed where
import Prelude hiding ((>>=), (>>))
class IxFunctor f where
imap :: (a -> b) -> f j k a -> f j k b
class IxFunctor f => IxPointed f where
ireturn :: a -> f i i a
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleInstances, TupleSections #-}
import Prelude hiding (repeat)
class Functor w => Comonad w where
extract :: w a -> a
extend :: (w a -> b) -> (w a -> w b)
data Product e a = Product e a
import Window
import Mouse
fpsCount = 35
delta = fps fpsCount
time = foldp (+) 0.0 delta
timeSeconds = (\ x -> x / 1000.0) <~ time
black = rgb 0 0 0
display (w, h) (x, y) t =
module Refresher where
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + n = n
succ n + m = succ (n + m)