From ea6409e95bed49864c0feb8aa00230174e8b9998 Mon Sep 17 00:00:00 2001 From: Johannes Hellrich Date: Thu, 9 Mar 2017 21:44:09 +0100 Subject: [PATCH 1/2] made meetLambdaHigherOrderFunctions more interesting --- src/main/scala/stdlib/HigherOrderFunctions.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/stdlib/HigherOrderFunctions.scala b/src/main/scala/stdlib/HigherOrderFunctions.scala index 8b7bdf71..0c1e1b68 100644 --- a/src/main/scala/stdlib/HigherOrderFunctions.scala +++ b/src/main/scala/stdlib/HigherOrderFunctions.scala @@ -13,11 +13,11 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis */ def meetLambdaHigherOrderFunctions(res0: Int, res1: Int, res2: Int, res3: Int, res4: Int, res5: Int) { def lambda = { x: Int ⇒ x + 1 } - def lambda2 = (x: Int) ⇒ x + 1 - val lambda3 = (x: Int) ⇒ x + 1 + def lambda2 = (x: Int) ⇒ x + 2 + val lambda3 = (x: Int) ⇒ x + 3 val lambda4 = new Function1[Int, Int] { - def apply(v1: Int): Int = v1 + 1 + def apply(v1: Int): Int = v1 - 1 } def lambda5(x: Int) = x + 1 @@ -31,10 +31,10 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis val result5 = lambda5(3) result should be(res0) - result1andhalf should be(res1) - result2 should be(res2) - result3 should be(res3) - result4 should be(res4) + result1andhalf should be(res1+1) + result2 should be(res2+2) + result3 should be(res3+3) + result4 should be(res4-1) result5 should be(res5) } From d74c470dd6d89f6a724da0906bb716c70620160d Mon Sep 17 00:00:00 2001 From: hellrich Date: Thu, 9 Mar 2017 22:57:03 +0100 Subject: [PATCH 2/2] tests working --- src/main/scala/stdlib/HigherOrderFunctions.scala | 8 ++++---- src/test/scala/stdlib/HigherOrderFunctionsSpec.scala | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/stdlib/HigherOrderFunctions.scala b/src/main/scala/stdlib/HigherOrderFunctions.scala index 0c1e1b68..36fef0a8 100644 --- a/src/main/scala/stdlib/HigherOrderFunctions.scala +++ b/src/main/scala/stdlib/HigherOrderFunctions.scala @@ -31,10 +31,10 @@ object HigherOrderFunctions extends FlatSpec with Matchers with org.scalaexercis val result5 = lambda5(3) result should be(res0) - result1andhalf should be(res1+1) - result2 should be(res2+2) - result3 should be(res3+3) - result4 should be(res4-1) + result1andhalf should be(res1) + result2 should be(res2) + result3 should be(res3) + result4 should be(res4) result5 should be(res5) } diff --git a/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala b/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala index 67ac2caf..9d4e6714 100644 --- a/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala +++ b/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala @@ -11,7 +11,7 @@ class HigherOrderFunctionsSpec extends Spec with Checkers { check( Test.testSuccess( HigherOrderFunctions.meetLambdaHigherOrderFunctions _, - 4 :: 4 :: 4 :: 4 :: 4 :: 4 :: HNil + 4 :: 4 :: 5 :: 6 :: 2 :: 4 :: HNil ) ) }