Skip to content

Instantly share code, notes, and snippets.

View jasonreich's full-sized avatar

Jason Reich jasonreich

View GitHub Profile
@copumpkin
copumpkin / gist:4759099
Last active December 12, 2015 10:29
zipWith/foldr challenge!
-- This is the type we're working with.
data List a = List (forall r. (a -> r -> r) -> r -> r)
-- Implement this signature. It should not be inefficient, so if you're planning
-- on writing something like tail (notoriously inefficient using foldr) on our
-- List type, think again! It should be possible to write with the same time
-- complexity as the original. And of course, converting to/from a conventional
-- list is cheating :)
zipWith :: (a -> b -> c) -> List a -> List b -> List c
@copumpkin
copumpkin / Nicomachus.agda
Last active October 3, 2015 00:38
Nicomachus's theorem
module Nicomachus where
open import Function
open import Relation.Binary.PropositionalEquality
import Relation.Binary.EqReasoning as EqReasoning
open import Data.Nat
open import Data.Nat.Properties
-- http://en.wikipedia.org/wiki/Nicomachus%27s_theorem