Skip to content

Commit 64cca7b

Browse files
committed
Add Reducer for LazyK
1 parent 6197b6d commit 64cca7b

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

catculator-core/src/main/scala/pl/writeonly/catculator/core/calculators/lazyk/Reducer.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.util.Right
1212
object Reducer {
1313
def reduce(f: ADTBT): ADTBTSafe = f match {
1414
case Node(x, y) => applyM(reduce(x), reduce(y))
15-
case x => Right(x)
15+
case x => Right(x)
1616
}
1717

1818
def applyM(fM: ADTBTSafe, xM: ADTBTSafe): ADTBTSafe =
@@ -32,8 +32,6 @@ object Reducer {
3232
case _ => Right(Node(f, x))
3333
}
3434

35-
36-
3735
private def succ(x: ADTBT) = x match {
3836
case Leaf(ADT.Num(x)) => Right(Leaf(ADT.Num(x + Natural.one)))
3937
case _ => Left(s"attempted to apply inc to a non-number $x")

catculator-core/src/test/scala/pl/writeonly/catculator/core/parsers/HaskellSpec.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@ class HaskellSpec extends TableDrivenPropertySpec {
139139
(HelloWorld5, "`apply `\\a \\b (a) \\const `apply `(const const) \\main main"),
140140
)
141141

142-
val programs: TableFor3[String, String, String] = Table(
143-
("function", "input", "output"),
144-
(Empty, "", ""),
145-
(HelloWorld, "", ""),
146-
(Factorial, "", ""),
147-
)
142+
val programs: TableFor3[String, String, String] = Table(("function", "input", "output"), (Empty, "", ""), (HelloWorld, "", ""), (Factorial, "", ""))
148143

149144
it should "parse sinpleFunctions and save lambda" in {
150145
forAll(simpleFunctions) { (function, lambda) =>

catculator-core/src/test/scala/pl/writeonly/catculator/core/parsers/LambdaSpec.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@ class LambdaSpec extends TableDrivenPropertySpec {
1818
("`a a", App(Var("a"), Var("a")), "`a a"),
1919
("\\a `a a", Abs("a", App(Var("a"), Var("a"))), "``S I I"),
2020
("\\a \\a a", Abs("a", Abs("a", Var("a"))), "`K I"),
21-
(
22-
"\\a \\b `a b",
23-
Abs("a", Abs("b", App(Var("a"), Var("b")))),
24-
"``S ``S `K S ``S `K K I `K I"
25-
),
26-
(
27-
"\\a \\b `b a",
28-
Abs("a", Abs("b", App(Var("b"), Var("a")))),
29-
"``S `K `S I ``S `K K I"
30-
),
21+
("\\a \\b `a b", Abs("a", Abs("b", App(Var("a"), Var("b")))), "``S ``S `K S ``S `K K I `K I"),
22+
("\\a \\b `b a", Abs("a", Abs("b", App(Var("b"), Var("a")))), "``S `K `S I ``S `K K I"),
3123
)
3224

3325
val advancedLambda: TableFor3[String, String, String] = Table(

0 commit comments

Comments
 (0)