This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- Discrete Mathematics Using a Computer | |
Chapter 11: Functions | |
-} | |
module Functions where | |
import Data.Tuple (swap) | |
-- ============================================================================= | |
-- 11.1 The Graph of a Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- 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) | |
-- ============================================================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- Discrete Mathematics Using a Computer | |
Chapter 09: Inductively Defined Sets | |
-} | |
module IndSet where | |
-- ============================================================================= | |
-- 9.1: The Idea Behind Induction | |
{- Suppose we have know that: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- Discrete Mathematics Using a Computer | |
Chapter 08: Sets | |
-} | |
module Sets where | |
type Set a = [a] | |
-- Note, this definition prevents us from having heterogeneous sets | |
-- TODO: use hlist (http://homepages.cwi.nl/~ralf/HList/) ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#+TITLE: DiscreteMathComputer 07-Predicate Logic | |
#+DATE: | |
#+LATEX_HEADER: \usepackage{fullpage} | |
#+OPTIONS: H:3 toc:nil | |
* Introduction: Why Predicates Logic | |
- Want to make the statement that everything has a certain property | |
+ e.g. "All men are mortal" | |
- Propositional Logic doesn't provide us any structure to express this | |
+ e.g. could say "P = all men are mortal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- Discrete Math Using a Computer | |
Chapter 6: Propositional Logic | |
Review Exercise | |
-} | |
import Stdm | |
-------------------------------------------------------------------------------- | |
-- Exercise 34: Prove A ^ ~A |- False |
NewerOlder