Skip to content

Instantly share code, notes, and snippets.

@kanak
kanak / DiscreteMathComputer09.hs
Created March 18, 2011 01:55
Discrete Mathematics Using a Computer Chapter 09: Inductively Defined Sets Solutions
{- Discrete Mathematics Using a Computer
Chapter 09: Inductively Defined Sets
-}
module IndSet where
-- =============================================================================
-- 9.1: The Idea Behind Induction
{- Suppose we have know that:
@kanak
kanak / DiscreteMathComputer10.hs
Created March 20, 2011 04:51
Discrete Mathematics Using a Computer Chapter 10: Relations Notes and Solutions
{- Discrete Mathematics Using a Computer
Chapter 10: Relations
-}
module Relations where
import List (nub)
import Stdm (setEq, union, isWeakest, isGreatest, isQuasiOrder, isLinearOrder)
import Data.Tuple (swap)
-- =============================================================================
@kanak
kanak / DiscreteMathComputer10.hs
Created March 22, 2011 04:01
Discrete Mathematics Using a Computer Chapter 11: Functions Notes and Solutions
{- Discrete Mathematics Using a Computer
Chapter 11: Functions
-}
module Functions where
import Data.Tuple (swap)
-- =============================================================================
-- 11.1 The Graph of a Function
@kanak
kanak / DiscreteMathComputer12.hs
Created March 24, 2011 21:20
Discrete Mathematics Using a Computer Chapter 12: AVL Tree Notes and Solutions
{- Discrete Mathematics Using a Computer
Chapter 12: AVL Trees
AVL Trees: Self-balancing binary trees.
-}
module AVL where
data SearchTree k d = Leaf
| Node k d (SearchTree k d) (SearchTree k d)
deriving (Show)
@kanak
kanak / DiscreteMathComputer13.hs
Created March 24, 2011 21:45
Discrete Mathematics Using a Computer Chapter 13: Circuit Simulation
{- Discrete Mathematics Using a Computer
Chapter 13: Circuit Simulation
Story: verify circuit properties using math because actually building and
testing is expensive.
-}
module Main where
import Data.List (intersperse)
-- Signal is anything that can be manipulated by circuits
@kanak
kanak / Bird01.lhs
Created March 25, 2011 20:35
Bird's Introduction to Functional Programming: Chapter 01 Fundamental Concepts Notes and Solutions
Richard Bird - Introduction to Functional Programming using Haskell [2ed]
Chapter 01: Fundamental Concepts
> module Bird01 where
> import Prelude hiding (pi, signum, abs)
================================================================================
1.1 Sessions and Scripts
Some definitions from the book. I've used more general type signatures.
@kanak
kanak / Bird02.lhs
Created March 26, 2011 00:19
Bird's Introduction to Functional Programming: Chapter 02 Simple Datatypes Notes and Solutions
Richard Bird - Introduction to Functional Programming using Haskell [2ed]
Chapter 02: Simple Datatypes
> module Bird02 where
> import Data.Char (chr, ord)
================================================================================
2.1 Booleans
> data Bool' = False' | True'