Skip to content
Snippets Groups Projects
Commit 5faaf413 authored by Philippe Suter's avatar Philippe Suter
Browse files

starting to plug the parts

parent 0c455173
No related branches found
No related tags found
No related merge requests found
import scala.collection.immutable.Set
object ParseMe {
sealed abstract class Tree
case class Node(left: Tree, value: Int, right: Tree) extends Tree
case class Leaf() extends Tree
def insert(v: Int, t: Tree): Tree = t match {
case Leaf() => Node(Leaf(), v, Leaf())
case Node(left, v2, right) if v2 > v => Node(insert(v, left), v2, right)
case Node(left, v2, right) if v2 < v => Node(left, v2, insert(v, right))
case n @ Node(left, v2, right) if v2 == v => n
}
def emptySet() : Tree = {
Leaf()
}
}
......@@ -33,4 +33,14 @@ object Analysis {
BooleanLiteral(false)
}
}
def flatten(expr: Expr) : (Expr,List[(Variable,Expr)]) = {
// Recursively flattens the expression. The head in the end
// should be the top-level original expression.
def fl(expr: Expr, lets: List[(Variable,Expr)]) : List[(Variable,Expr)] = expr match {
case _ => throw new Exception("ah ha !")
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment