Skip to content

Commit 13dacab

Browse files
Adds minor upgrade to stdlib exercises (#149)
* Adds minor upgrade to stdlib exercises * Moves to openjdk
1 parent 66495e5 commit 13dacab

9 files changed

+34
-24
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
dist: xenial
12
language: scala
23
scala:
3-
- 2.11.11
4+
- 2.11.12
45
jdk:
5-
- oraclejdk8
6+
- openjdk8
67
script:
78
- sbt test
89

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
val scalaExercisesV = "0.4.0-SNAPSHOT"
22

3-
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExercisesV
3+
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExercisesV excludeAll(ExclusionRule("io.monix"))
44

55
lazy val stdlib = (project in file("."))
66
.enablePlugins(ExerciseCompilerPlugin)

project/ProjectPlugin.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ object ProjectPlugin extends AutoPlugin {
1212

1313
override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin
1414

15+
object autoImport {
16+
17+
lazy val V = new {
18+
val scala211: String = "2.11.12"
19+
}
20+
}
21+
22+
import autoImport._
23+
24+
1525
override def projectSettings: Seq[Def.Setting[_]] =
1626
Seq(
1727
description := "Scala Exercises: The path to enlightenment",
@@ -25,9 +35,9 @@ object ProjectPlugin extends AutoPlugin {
2535
organizationEmail = "[email protected]"
2636
),
2737
orgLicenseSetting := ApacheLicense,
28-
scalaVersion := "2.11.11",
38+
scalaVersion := V.scala211,
2939
scalaOrganization := "org.scala-lang",
30-
crossScalaVersions := Seq("2.11.11"),
40+
crossScalaVersions := Seq(V.scala211),
3141
resolvers ++= Seq(
3242
Resolver.mavenLocal,
3343
Resolver.sonatypeRepo("snapshots"),
@@ -41,7 +51,7 @@ object ProjectPlugin extends AutoPlugin {
4151
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4252
| */
4353
|
44-
|""".stripMargin)
54+
|""".stripMargin)
4555
)
4656
)
4757
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.13
1+
sbt.version=0.13.15

src/main/scala/stdlib/HigherOrderFunctions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ object HigherOrderFunctions
8787
}
8888

8989
/** And then we get to Higher Order Functions:
90-
* Higher Order Functions are functions that take functions as arguments and/or return functions.
91-
*
92-
* We can take that closure and throw it into a Higher Order Function and it will still hold the environment:
90+
* Higher Order Functions are functions that take functions as arguments and/or return functions.
91+
*
92+
* We can take that closure and throw it into a Higher Order Function and it will still hold the environment:
9393
*/
9494
def holdEnvironmentHigherOrderFunctions(res0: Int, res1: Int) {
9595
def summation(x: Int, y: Int Int) = y(x)

src/main/scala/stdlib/Ranges.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Ranges extends FlatSpec with Matchers with org.scalaexercises.definitions
1515
/** 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".
1616
*
1717
* 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".
18-
*
18+
*
1919
* Note that `Range(a, b, c)` is the same as `a until b by c`
2020
*
2121
* 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.

src/main/scala/stdlib/Traits.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,21 @@ object Traits extends FlatSpec with Matchers with org.scalaexercises.definitions
100100
myListener.isInstanceOf[Any] should be(res2)
101101
myListener.isInstanceOf[AnyRef] should be(res3)
102102
}
103-
103+
104104
/** 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.
105-
*
105+
*
106106
* Also, the dependencies can't have identical method/property names or else you'll get an `illegal inheritance` error.
107107
*/
108-
def selfTypeTraits(res0: Int){
108+
def selfTypeTraits(res0: Int) {
109109
trait B {
110110
def bId = 2
111-
}
112-
113-
trait A {
114-
self: B =>
115-
111+
}
112+
113+
trait A { self: B =>
114+
116115
def aId = 1
117116
}
118-
117+
119118
//val a = new A //***does not compile!!!***
120119
val obj = new A with B
121120
(obj.aId + obj.bId) should be(res0)

src/main/scala/stdlib/Traversables.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Traversables extends FlatSpec with Matchers with org.scalaexercises.defin
2424
*
2525
* 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`.
2626
*
27-
* 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.
27+
* 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.
2828
`++` appends two `Traversable`s together. The resulting `Traversable` is the same type of the first element.
2929
*/
3030
def topOfCollectionTraversables(res0: Int, res1: Int) {
@@ -514,8 +514,8 @@ object Traversables extends FlatSpec with Matchers with org.scalaexercises.defin
514514
/** The naive recursive implementation of `reduceRight` is not tail recursive and would lead to a stack overflow if used on larger traversables.
515515
* However, `reduceLeft` can be implemented with tail recursion.
516516
*
517-
* 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.
518-
* The same applies for folding operations.
517+
* 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.
518+
* The same applies for folding operations.
519519
*
520520
* 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`).
521521
*/

version.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version in ThisBuild := "0.4.2-SNAPSHOT"
1+
version in ThisBuild := "0.5.0-SNAPSHOT"

0 commit comments

Comments
 (0)