Skip to content

Instantly share code, notes, and snippets.

Michael Dunsmuir mdunsmuir

Block or report user

Report or block mdunsmuir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hot-dogs.hs
module Main where
import Control.Monad (when)
import System.Environment (getArgs)
import Data.List (intersperse)
fibo :: [Int]
fibo = 0 : 1 : zipWith (+) fibo (tail fibo)
hotDogsOnDay :: Int -> Int
View y.js
function fix(f) {
return function(x) {
return f(x)(fix(f));
var fac = function(x) {
if(x == 1) {
return function(_) {
return 1;
View slurm_ffi.rb
# Generated by ffi_gen. Please do not change this file by hand.
require 'ffi'
module Slurm
extend FFI::Library
ffi_lib "slurm"
def self.attach_function(name, *_)
begin; super; rescue FFI::NotFoundError => e
View hanoi.hs
{-# LANGUAGE RankNTypes #-}
import Data.Functor.Identity
import Graphics.Gloss
-- * types
type Lens s a = forall f. Functor f => (a -> f a) -> s -> f s
ix :: Int -> Lens [a] a
View ShowIP.hs
import System.Environment
import Control.Exception
import Control.Monad
import Network.Socket
main = do
args <- getArgs
case args of
[host] -> catch (displayIPs host) $ \e -> do
let err = show (e :: IOException)
View Hudooku.hs
{-# LANGUAGE TupleSections #-}
import System.Environment
import Control.Monad
import qualified Data.Attoparsec.Text as P
import Data.Maybe
import Data.List
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import qualified Data.Map as M
mdunsmuir / Trie.hs
Last active Aug 29, 2015
given an input 'dictionary' (a list of words) and a string, determine whether the string is an arbitrary concatenation of the words in the dictionary
View Trie.hs
module Trie (
) where
import Data.Maybe
import Data.List (foldr)
View StateT.hs
{-# LANGUAGE MultiParamTypeClasses,
FlexibleInstances #-}
module StateT (
--StateT, runStateT,
State, runState,
module Control.Applicative,
module Control.Monad,
View f-algebras.hs
-- common
data Fix a = Fx (a (Fix a))
unfix :: Fix a -> a (Fix a)
unfix (Fx f) = f
type Algebra f a = f a -> a
cata :: Functor f => (f a -> a) -> Fix f -> a
View PascalsTriangle.hs
module PascalsTriangle (pascalsTriangle) where
import Control.Applicative
import Test.QuickCheck
pascalsTriangle :: [[Int]]
pascalsTriangle = [1] : map row pascalsTriangle
where row prev = zipWith (+) (0 : prev) (prev ++ [0])
-- quickcheck stuff
You can’t perform that action at this time.