Skip to content

Commit

Permalink
Fix: Markdown headers
Browse files Browse the repository at this point in the history
  • Loading branch information
divarvel committed Nov 28, 2011
1 parent b45e129 commit bd56992
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Arithmetic Trees
================

**Purpose** This is just the port of Java practicals at École Centrale de
## Purpose
This is just the port of Java practicals at École Centrale de
Nantes. The goal is to describe polynomials as trees, then evaluate them or derive
them. Since I'm fairly new to Haskell, this code has been written just for
fun. Comments are welcome !

**Usage**
## Usage

..Define a tree..
### Define a tree

let plus = Binary Plus (Leaf (Val 2)) (Leaf X) -- (2 + x)
let cos = Unary Cos (Leaf X) -- cos(x)
Expand All @@ -26,20 +27,20 @@ notation.

((42 + 10) * x)

..Evaluate a tree..
### Evaluate a tree

eval (Binary Pow (Leaf (Val x)) (Leaf (Val 2))) -- 4

..Evaluate a tree for a given value..
### Evaluate a tree for a given value

eval (replace (Binary Pow (Leaf (Val x)) (Leaf (Val 2))) 2) -- 4


..Derive a tree..
### Derive a tree

derive (Binary Plus (Binary Times (Leaf (X)) (Leaf (Val 12))) (Leaf (X)))

..Clean a tree..
### Clean a tree
The derived tree is often unnecessarily cluttered. You can clean it by
simplifying (`1*x`, `0*x`, `0+x` and so on).

Expand Down

0 comments on commit bd56992

Please sign in to comment.