diff --git a/.travis.yml b/.travis.yml index 9b09eab4..b1809195 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ +dist: xenial language: scala scala: -- 2.11.11 +- 2.11.12 jdk: -- oraclejdk8 +- openjdk8 script: - sbt test diff --git a/build.sbt b/build.sbt index b4104684..54cfb27a 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val scalaExercisesV = "0.4.0-SNAPSHOT" -def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExercisesV +def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExercisesV excludeAll(ExclusionRule("io.monix")) lazy val stdlib = (project in file(".")) .enablePlugins(ExerciseCompilerPlugin) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 17c1b2ce..55392152 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -12,6 +12,16 @@ object ProjectPlugin extends AutoPlugin { override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin + object autoImport { + + lazy val V = new { + val scala211: String = "2.11.12" + } + } + + import autoImport._ + + override def projectSettings: Seq[Def.Setting[_]] = Seq( description := "Scala Exercises: The path to enlightenment", @@ -25,9 +35,9 @@ object ProjectPlugin extends AutoPlugin { organizationEmail = "hello@47deg.com" ), orgLicenseSetting := ApacheLicense, - scalaVersion := "2.11.11", + scalaVersion := V.scala211, scalaOrganization := "org.scala-lang", - crossScalaVersions := Seq("2.11.11"), + crossScalaVersions := Seq(V.scala211), resolvers ++= Seq( Resolver.mavenLocal, Resolver.sonatypeRepo("snapshots"), @@ -41,7 +51,7 @@ object ProjectPlugin extends AutoPlugin { | * Copyright (C) 2015-2016 47 Degrees, LLC. | */ | - |""".stripMargin) + |""".stripMargin) ) ) } diff --git a/project/build.properties b/project/build.properties index 5f32afe7..cf19fd02 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.13 \ No newline at end of file +sbt.version=0.13.15 \ No newline at end of file diff --git a/src/main/scala/stdlib/HigherOrderFunctions.scala b/src/main/scala/stdlib/HigherOrderFunctions.scala index c3a83cfd..2f74c1b4 100644 --- a/src/main/scala/stdlib/HigherOrderFunctions.scala +++ b/src/main/scala/stdlib/HigherOrderFunctions.scala @@ -87,9 +87,9 @@ object HigherOrderFunctions } /** And then we get to Higher Order Functions: - * Higher Order Functions are functions that take functions as arguments and/or return functions. - * - * We can take that closure and throw it into a Higher Order Function and it will still hold the environment: + * Higher Order Functions are functions that take functions as arguments and/or return functions. + * + * We can take that closure and throw it into a Higher Order Function and it will still hold the environment: */ def holdEnvironmentHigherOrderFunctions(res0: Int, res1: Int) { def summation(x: Int, y: Int ⇒ Int) = y(x) diff --git a/src/main/scala/stdlib/Ranges.scala b/src/main/scala/stdlib/Ranges.scala index 64a5f81c..0e1daf53 100644 --- a/src/main/scala/stdlib/Ranges.scala +++ b/src/main/scala/stdlib/Ranges.scala @@ -15,7 +15,7 @@ object Ranges extends FlatSpec with Matchers with org.scalaexercises.definitions /** A Range is an ordered sequence of integers that are equally spaced apart. For example, "1, 2, 3" is a range, as is "5, 8, 11, 14". To create a range in Scala, use the predefined methods `to`, `until`, and `by`. `1 to 3` generates "1, 2, 3" and `5 to 14 by 3` generates "5, 8, 11, 14". * * If you want to create a range that is exclusive of its upper limit, then use `until` instead of `to`: `1 until 3` generates "1, 2". - * + * * Note that `Range(a, b, c)` is the same as `a until b by c` * * Ranges are represented in constant space, because they can be defined by just three numbers: their start, their end, and the stepping value. Because of this representation, most operations on ranges are extremely fast. diff --git a/src/main/scala/stdlib/Traits.scala b/src/main/scala/stdlib/Traits.scala index e54d4d1c..405a950d 100644 --- a/src/main/scala/stdlib/Traits.scala +++ b/src/main/scala/stdlib/Traits.scala @@ -100,22 +100,21 @@ object Traits extends FlatSpec with Matchers with org.scalaexercises.definitions myListener.isInstanceOf[Any] should be(res2) myListener.isInstanceOf[AnyRef] should be(res3) } - + /** Traits also can use self-types. A self-type lists the required dependencies for mixing in the trait. When mixing in the main trait, all self-type dependencies of that trait must also be mixed in, otherwise a compile-time error is thrown. - * + * * Also, the dependencies can't have identical method/property names or else you'll get an `illegal inheritance` error. */ - def selfTypeTraits(res0: Int){ + def selfTypeTraits(res0: Int) { trait B { def bId = 2 - } - - trait A { - self: B => - + } + + trait A { self: B => + def aId = 1 } - + //val a = new A //***does not compile!!!*** val obj = new A with B (obj.aId + obj.bId) should be(res0) diff --git a/src/main/scala/stdlib/Traversables.scala b/src/main/scala/stdlib/Traversables.scala index 70fa4605..19e5be26 100644 --- a/src/main/scala/stdlib/Traversables.scala +++ b/src/main/scala/stdlib/Traversables.scala @@ -24,7 +24,7 @@ object Traversables extends FlatSpec with Matchers with org.scalaexercises.defin * * The `foreach` method is meant to traverse all elements of the collection, and apply the given operation, `f`, to each element. The type of the operation is `Elem => U`, where `Elem` is the type of the collection's elements and `U` is an arbitrary result type. The invocation of `f` is done for its side effect only; in fact any function result of `f` is discarded by `foreach`. * - * Traversables are the superclass of `List`, `Array`, `Map`, `Set`, `Stream` and more. The methods involved can be applied to each other in a different type. + * Traversables are the superclass of `List`, `Array`, `Map`, `Set`, `Stream` and more. The methods involved can be applied to each other in a different type. `++` appends two `Traversable`s together. The resulting `Traversable` is the same type of the first element. */ def topOfCollectionTraversables(res0: Int, res1: Int) { @@ -514,8 +514,8 @@ object Traversables extends FlatSpec with Matchers with org.scalaexercises.defin /** The naive recursive implementation of `reduceRight` is not tail recursive and would lead to a stack overflow if used on larger traversables. * However, `reduceLeft` can be implemented with tail recursion. * - * To avoid the potential stack overflow with the naive implementation of `reduceRight` we can easily implement it based on `reduceLeft` by reverting the list and the inverting the reduce function. - * The same applies for folding operations. + * To avoid the potential stack overflow with the naive implementation of `reduceRight` we can easily implement it based on `reduceLeft` by reverting the list and the inverting the reduce function. + * The same applies for folding operations. * * There is also a `reduce` (and `fold`) available, which works exactly like `reduceLeft` (and `foldLeft`) and it should be the prefered method to call unless there is a strong reason to use `reduceRight` (or `foldRight`). */ diff --git a/version.sbt b/version.sbt index 11c590d8..404aa03e 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.4.2-SNAPSHOT" +version in ThisBuild := "0.5.0-SNAPSHOT"