Skip to content

Instantly share code, notes, and snippets.

View rjwebb's full-sized avatar

Bob Webb rjwebb

View GitHub Profile
betweenTimes :: Integral b => b -> Time -> Time -> Time -> Bool
betweenTimes n s e t = and [normT >= s, normT < e] where normT = fromIntegral (mod (floor t) n)
playForLoop :: Integral b => b -> Time -> Time -> Pattern a -> Pattern a
playForLoop n s e = playWhen (betweenTimes n s e)
seqPLoop :: Integral b => b -> [(Time, Time, Pattern a)] -> Pattern a
seqPLoop n = stack . (map (\(s, e, p) -> playForLoop n s e ((sam s) ~> p)))
@rjwebb
rjwebb / unification.hs
Created November 23, 2013 13:11
An implementation of the type unification algorithm [1], using simple types. Used the explanation in this week's Comparative Programming lecture as reference.
import qualified Data.Maybe as M
import Debug.Trace
-- Type type
data Type = Val Char | Arrow Type Type deriving Eq
instance Show Type where
show (Val c) = [c]
show (Arrow t1 t2) = "(" ++ (show t1) ++ " -> " ++ (show t2) ++ ")"
-- Substitution type
@rjwebb
rjwebb / mandelbrotGenerator.py
Created June 5, 2012 12:50
Mandelbrot Set generator and fractal viewer
#/bin/python
# Mandelbrot pattern generator by Bob Webb, 2012.
# Generates a Mandelbrot pattern as a 2D array of numerical values (number of iterations) that's then pickled.
# I need to get round to pickling metadata as well but not now. Har har.
import sys
import numpy
import pickle
import math