exercises-scalatutorial
exercises-scalatutorial copied to clipboard
Exercises for the "Functional Programming Principles in Scala", part of the FP in Scala specialized program by EPFL.
if you run: ``` var rec = 0 def llRange(lo: Int, hi: Int): LazyList[Int] = { rec = rec + 1 if (lo >= hi) LazyList.empty else LazyList.cons(lo, llRange(lo +...
the original `val cond: (Int, Int) => Boolean = ` has to be pretty hard for beginners (no notion about `_` before, also functions (`val`) are not so common than...
Add one more condition to trigger accurate error messages
x = 0 is not going to affect value of "result", better to set it to some non-zero value.
Replace "Shadowed defintions" by "Shadowed definitions"
As an example, on OSX with Scala version `2.13.1`, I see ``` scala> def average(x: Int, xs: Int*): Double = | (x :: xs.to(List)).sum.toDouble / (xs.size + 1) :13: error:...