Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala3 #734

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Installing [Scala](http://www.scala-lang.org)

Scala can run on the JVM, but also has support for JS integration and even compilation to native code.
For help install various dependencies, consider using [Scala-CLI](https://scala-cli.virtuslab.org/)

In addition to the exercism CLI and your favorite text editor, practicing with Exercism exercises in Scala requires:
Another alternative is [SDKMAN](https://sdkman.io/)
to manage your Java and Java-adjacent development tools and libraries.

If you do wish to have full control over package installation, you need to manually install

* Java Development Kit (JDK) 17 or later. Use your preferred vendor or grab one from [Adoptium](https://adoptium.net/)
* [Scala 2.13.x](https://www.scala-lang.org/download/scala2.html)
* [Scala 3.1.x](https://www.scala-lang.org/download/)
* [sbt 1.7.x](https://www.scala-sbt.org/download.html)

If you don't want install these various dependencies by hand, consider using [SDKMAN](https://sdkman.io/) to manage your java and java-adjacent development tools and libraries.


---

Expand All @@ -20,7 +25,8 @@ To get started, see "[Running the Tests](https://exercism.org/docs/tracks/scala/
# Scala IDEs

* [IntelliJ IDEA with Scala Plugin](https://www.jetbrains.com/idea/)
* [ScalaIDE](http://scala-ide.org/index.html)
* [VS Code with Metals](https://scalameta.org/metals/docs/editors/vscode)
* [Vim or Neovim with Metals](https://scalameta.org/metals/docs/editors/vim)
* [Sublime with Metals](https://scalameta.org/metals/docs/editors/sublime)
* [Emacs with Metals](https://scalameta.org/metals/docs/editors/emacs)
* [NetBeans with Scala Plugin](https://netbeans.org/)
* [Metals with VS Code](https://scalameta.org/metals/docs/editors/vscode)
* [Metals with Vim or Neovim](https://scalameta.org/metals/docs/editors/vim)
24 changes: 20 additions & 4 deletions docs/LEARNING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# Learning

## Online Courses


* [The Scala Center](https://docs.scala-lang.org/online-courses.html) - The Scala Center is an independent not-for-profit center focused on open source and
learning. They have a syllabus and links to various learning platforms.
* [Functional Programming Principles in Scala](https://www.coursera.org/learn/progfun1) - In this course you will discover the elements of the functional programming style and learn how to apply them usefully in your daily programming tasks. You will also develop a solid foundation for reasoning about functional programs, by touching upon proofs of invariants and the tracing of execution symbolically.
* [Functional Program Design in Scala](https://www.coursera.org/learn/progfun2) - In this course you will learn how to apply the functional programming style in the design of larger applications.

## Books

* [Learn Scala 3 the Fast Way - Alvin Alexander](https://alvinalexander.com/scala/learn-scala-3-the-fast-way-book/)
* [Hands on Scala Programming - Li Haoyi](https://www.handsonscala.com/)
* [Programming Scala - Dean Wampler, Ph.D.](http://shop.oreilly.com/product/0636920033073.do)
* [Programming in Scala - Oderksy, Spoon, Venners](http://www.artima.com/shop/programming_in_scala_3ed)
* [Functional Programming in Scala - Chiusano, Bjarnason](https://www.manning.com/books/functional-programming-in-scala)
* [Scala for the Impatient - Cay S. Horstmann](http://horstmann.com/scala/)
* [Hands on Scala Programming - Li Haoyi](https://www.handsonscala.com/)

## Online Courses
## Free Online Books

* [Functional Programming Principles in Scala](https://www.coursera.org/learn/progfun1) - In this course you will discover the elements of the functional programming style and learn how to apply them usefully in your daily programming tasks. You will also develop a solid foundation for reasoning about functional programs, by touching upon proofs of invariants and the tracing of execution symbolically.
* [Functional Program Design in Scala](https://www.coursera.org/learn/progfun2) - In this course you will learn how to apply the functional programming style in the design of larger applications.
* [EBook Foundations List of Free Programming Books](https://github.com/EbookFoundation/free-programming-books/blob/main/books/free-programming-books-langs.md#scala)

## Youtube channels

* [Dr Mark Lewis](https://www.youtube.com/user/drmarkclewis)
* [Scala In The City](https://www.youtube.com/c/ScalaintheCity/)
* [Rock the JVM](https://www.youtube.com/c/RocktheJVM/)
* [Konfy](https://www.youtube.com/c/Konfy/)
* [DevInsideYou](https://www.youtube.com/c/DevInsideYou)
15 changes: 11 additions & 4 deletions docs/RESOURCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

Exercism provides exercises and feedback but can be difficult to jump into for those learning Scala for the first time. These resources can help you get started:

* [Scala - Getting Started](http://www.scala-lang.org/documentation/getting-started.html)
* [StackOverflow](http://stackoverflow.com/)
* [Scala - Getting Started](https://docs.scala-lang.org/getting-started/index.html)
* [StackOverflow](https://stackoverflow.com/)
* [Scala Exercises](https://www.scala-exercises.org/std_lib)
* [The Neophyte's Guide to Scala](https://danielwestheide.com/books/the-neophytes-guide-to-scala/)

## Linting

Scala projects can be linted for further code analysis via a third party tool - [Scalastyle](http://www.scalastyle.org/).
Scala projects can be linted for further code analysis via a third party tool

There are several ways of using Scalastyle including Maven, SBT, Gradle, IntelliJ and Eclipse. For instructions on usage visit [Scalastyle](http://www.scalastyle.org/).
* [Scalafix](https://scalacenter.github.io/scalafix/)
* [Scalafmt](https://scalameta.org/scalafmt/#Scalafmt-codeformatterforScala)

## REPLs and scripting

* [Scastie - browser REPL](https://scastie.scala-lang.org/)
* [Ammonite shell REPL and scripting tools](http://ammonite.io/)
* [ScribbleNinja - Scala.js in your browser](https://scribble.ninja/)
7 changes: 1 addition & 6 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@ $ sbt
Note that all tests have been disabled except the first one for you to work on.
To continue, just remove the `pending` keyword from the beginning of each test case.

Tests can also be run within the following IDEs

* [IntelliJ IDEA with Scala Plugin](https://www.jetbrains.com/idea/)
* [ScalaIDE](http://scala-ide.org/index.html)
* [NetBeans with Scala Plugin](https://netbeans.org/)

Tests can also be run within the IDEs listed on the "Installing Scala Locally" page.
2 changes: 1 addition & 1 deletion exercises/concept/basics/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/accumulate/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/acronym/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/allergies/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/alphametics/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0"
2 changes: 1 addition & 1 deletion exercises/practice/anagram/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/bank-account/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/beer-song/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
10 changes: 7 additions & 3 deletions exercises/practice/binary-search-tree/.meta/Example.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import math.Ordered.orderingToOrdered

case class Bst[+T](value: T, left: Option[Bst[T]], right: Option[Bst[T]]) {
def insert[U >: T <% Ordered[U]](x: U): Bst[U] = {

def insert[U >: T](x: U)(implicit ord: Ordering[U]): Bst[U] = {

def insert(x: U, node: Option[Bst[U]]): Option[Bst[U]] =
node match {
case Some(n) => Option(n.insert(x))
Expand All @@ -12,7 +16,7 @@ case class Bst[+T](value: T, left: Option[Bst[T]], right: Option[Bst[T]]) {
}

object Bst {
def fromList[T <% Ordered[T]](l: List[T]): Bst[T] = l match {
def fromList[T](l: List[T])(implicit ord: Ordering[T]): Bst[T] = l match {
case x::xs => xs.foldLeft(Bst(x, None, None))((r, e) => r.insert(e))
case x::Nil => Bst(x, None, None)
case Nil => throw new IllegalArgumentException("Tree must not be empty")
Expand All @@ -26,4 +30,4 @@ object Bst {
}

def apply[T](x: T): Bst[T] = Bst(x, None, None)
}
}
2 changes: 1 addition & 1 deletion exercises/practice/binary-search-tree/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 2 additions & 0 deletions exercises/practice/binary-search/.meta/Example.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import scala.annotation.tailrec

import math.Ordering.Implicits.infixOrderingOps

object BinarySearch {
def find[T](seq: Seq[T], value: T)(implicit ord: T => Ordered[T]): Option[Int]
= searchInternal(seq, value, 0, seq.size - 1)
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/binary-search/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/binary/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/bob/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/book-store/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/bowling/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/change/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/clock/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/collatz-conjecture/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/complex-numbers/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ComplexNumberTest extends AnyFunSuite with Matchers {

private val equalityEpsilon = 1e-15

private def assertEquals(c1: ComplexNumber, c2: ComplexNumber) {
private def assertEquals(c1: ComplexNumber, c2: ComplexNumber) = {
c1.real should be (c2.real +- equalityEpsilon)
c1.imaginary should be (c2.imaginary +- equalityEpsilon)
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/connect/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/crypto-square/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/custom-set/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/darts/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/diamond/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/difference-of-squares/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/dominoes/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/etl/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/flatten-array/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/food-chain/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/forth/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.0"
2 changes: 1 addition & 1 deletion exercises/practice/gigasecond/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/grade-school/.meta/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class School {

def db: DB = _db

def add(name: String, g: Int) {
def add(name: String, g: Int) = {
_db = db.updated(g, grade(g) :+ name)
}

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/grade-school/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/grains/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/hamming/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/hello-world/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/hexadecimal/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/high-scores/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/house/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/isogram/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/kindergarten-garden/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

2 changes: 1 addition & 1 deletion exercises/practice/largest-series-product/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
2 changes: 1 addition & 1 deletion exercises/practice/leap/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.13.6"
scalaVersion := "3.1.3"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Loading