Skip to content
Snippets Groups Projects
Commit 2fc67c40 authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Corrected BinaryTreeRender.scala (Leaf() instead of Leaf)

parent abce83ac
Branches
Tags
No related merge requests found
/**
* Name: BinaryTreeRender.scala
* Creation: 14.10.2015
* Author: Mikal Mayer (mikael.mayer@epfl.ch)
* Author: Mika�l Mayer (mikael.mayer@epfl.ch)
* Comments: Binary tree rendering specifications.
*/
......@@ -18,56 +18,56 @@ object TreeRender {
/** Synthesis by example specs */
@inline def psStandard(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf))"
case Node(Leaf, 1, Leaf) => "Node(Leaf, 1, Leaf)"
case Leaf => "Leaf"
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf()))"
case Node(Leaf(), 1, Leaf()) => "Node(Leaf(), 1, Leaf())"
case Leaf() => "Leaf()"
}
@inline def psRemoveNode(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "((Leaf, 2, Leaf), 1, (Leaf, -3, Leaf))"
case Node(Leaf, 1, Leaf) => "(Leaf, 1, Leaf)"
case Leaf => "Leaf"
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "((Leaf(), 2, Leaf()), 1, (Leaf(), -3, Leaf()))"
case Node(Leaf(), 1, Leaf()) => "(Leaf(), 1, Leaf())"
case Leaf() => "Leaf()"
}
@inline def psRemoveLeaf(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "((, 2, ), 1, (, -3, ))"
case Node(Leaf, 1, Leaf) => "(, 1, )"
case Leaf => ""
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "((, 2, ), 1, (, -3, ))"
case Node(Leaf(), 1, Leaf()) => "(, 1, )"
case Leaf() => ""
}
@inline def psRemoveComma(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "((2), 1, (-3))"
case Node(Leaf, 1, Node(Leaf, 2, Leaf)) => "(1, (2))"
case Node(Node(Leaf, 2, Leaf), 1, Leaf) => "((2), 1)"
case Leaf => ""
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "((2), 1, (-3))"
case Node(Leaf(), 1, Node(Leaf(), 2, Leaf())) => "(1, (2))"
case Node(Node(Leaf(), 2, Leaf()), 1, Leaf()) => "((2), 1)"
case Leaf() => ""
}
@inline def psRemoveParentheses(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "(2), 1, (-3)"
case Node(Leaf, 1, Node(Leaf, 2, Leaf)) => "1, (2)"
case Node(Node(Leaf, 2, Leaf), 1, Leaf) => "(2), 1"
case Leaf => ""
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "(2), 1, (-3)"
case Node(Leaf(), 1, Node(Leaf(), 2, Leaf())) => "1, (2)"
case Node(Node(Leaf(), 2, Leaf()), 1, Leaf()) => "(2), 1"
case Leaf() => ""
}
@inline def psPrefix(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "1 (2) (-3)"
case Node(Leaf, 1, Node(Leaf, 2, Leaf)) => "1 () (2)"
case Node(Node(Leaf, 2, Leaf), 1, Leaf) => "1 (2) ()"
case Leaf => "()"
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "1 (2) (-3)"
case Node(Leaf(), 1, Node(Leaf(), 2, Leaf())) => "1 () (2)"
case Node(Node(Leaf(), 2, Leaf()), 1, Leaf()) => "1 (2) ()"
case Leaf() => "()"
}
@inline def psLispLike(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "(1 (2) (-3))"
case Node(Leaf, 1, Node(Leaf, 2, Leaf)) => "(1 () (2))"
case Node(Node(Leaf, 2, Leaf), 1, Leaf) => "(1 (2) ())"
case Leaf => "()"
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "(1 (2) (-3))"
case Node(Leaf(), 1, Node(Leaf(), 2, Leaf())) => "(1 () (2))"
case Node(Node(Leaf(), 2, Leaf()), 1, Leaf()) => "(1 (2) ())"
case Leaf() => "()"
}
@inline def psSuffix(s: Tree[Int])(res: String) = (s, res) passes {
case Node(Node(Leaf, 2, Leaf), 1, Node(Leaf, -3, Leaf)) => "(2) (-3) 1"
case Node(Leaf, 1, Node(Leaf, 2, Leaf)) => "() (2) 1"
case Node(Node(Leaf, 2, Leaf), 1, Leaf) => "(2) () 1"
case Leaf => "()"
case Node(Node(Leaf(), 2, Leaf()), 1, Node(Leaf(), -3, Leaf())) => "(2) (-3) 1"
case Node(Leaf(), 1, Node(Leaf(), 2, Leaf())) => "() (2) 1"
case Node(Node(Leaf(), 2, Leaf()), 1, Leaf()) => "(2) () 1"
case Leaf() => "()"
}
//////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment