diff --git a/Scala/docs/Parallel.md b/Scala/docs/Parallel.md index ae98080..37f71f9 100644 --- a/Scala/docs/Parallel.md +++ b/Scala/docs/Parallel.md @@ -65,9 +65,9 @@ val lf = vf.sequence map (_ reduce (_+_)) val l = Await.result(lf, 2.seconds) println(l) ``` -Crucially, this runs much faster than the corresponding sequential code. +Crucially, this runs much faster than the corresponding sequential code. However, it's still not as good as using parallel collections, since `map` and `reduce` are still the standard sequential versions, which are still $\mathcal{O}(n)$ operations. We could write our own `parMap` and `parReduce` methods, which use binary splitting to evaluate in parallel, but this is a bit beyond the scope of this very short course. ## Effects -Futures are a powerful and flexible way to construct parallel and concurrent applications. However, they aren't a perfect fit to a pure functional approach to programming. The fact that futures "fire" as soon as they are created means that they have a *side-effect* (such as creating a thread), and that is potentially problematic. People have developed more principled functional effects systems for Scala, such as [Cats effect](https://typelevel.org/cats-effect/) with its IO monad. These provide better mechanisms for parallel and concurrent programming in Scala. They are, however, (well) beyond the scope of this course. +Futures are a powerful and flexible way to construct parallel and concurrent applications. However, they aren't a perfect fit to a pure functional approach to programming. The fact that futures "fire" as soon as they are created means that they have a *side-effect* (such as creating a thread), and that is potentially problematic. People have developed more principled functional effects systems for Scala, such as [Cats effect](https://typelevel.org/cats-effect/) with its `IO` monad. These provide better mechanisms for parallel and concurrent programming in Scala. They are, however, (well) beyond the scope of this course. diff --git a/Scala/md/Parallel.md b/Scala/md/Parallel.md index ae66967..a75c3bb 100644 --- a/Scala/md/Parallel.md +++ b/Scala/md/Parallel.md @@ -7,7 +7,7 @@ This simplest (but by no means the only) way to get started with parallel progra Let's create some random data: ```scala val rng = scala.util.Random(42) -// rng: Random = scala.util.Random@18877d +// rng: Random = scala.util.Random@4fbdbb7 val v = Vector.fill(10)(rng.nextGaussian) // v: Vector[Double] = Vector( // 1.1419053154730547, @@ -98,9 +98,9 @@ val l = Await.result(lf, 2.seconds) println(l) // -4.844171665682075 ``` -Crucially, this runs much faster than the corresponding sequential code. +Crucially, this runs much faster than the corresponding sequential code. However, it's still not as good as using parallel collections, since `map` and `reduce` are still the standard sequential versions, which are still $\mathcal{O}(n)$ operations. We could write our own `parMap` and `parReduce` methods, which use binary splitting to evaluate in parallel, but this is a bit beyond the scope of this very short course. ## Effects -Futures are a powerful and flexible way to construct parallel and concurrent applications. However, they aren't a perfect fit to a pure functional approach to programming. The fact that futures "fire" as soon as they are created means that they have a *side-effect* (such as creating a thread), and that is potentially problematic. People have developed more principled functional effects systems for Scala, such as [Cats effect](https://typelevel.org/cats-effect/) with its IO monad. These provide better mechanisms for parallel and concurrent programming in Scala. They are, however, (well) beyond the scope of this course. +Futures are a powerful and flexible way to construct parallel and concurrent applications. However, they aren't a perfect fit to a pure functional approach to programming. The fact that futures "fire" as soon as they are created means that they have a *side-effect* (such as creating a thread), and that is potentially problematic. People have developed more principled functional effects systems for Scala, such as [Cats effect](https://typelevel.org/cats-effect/) with its `IO` monad. These provide better mechanisms for parallel and concurrent programming in Scala. They are, however, (well) beyond the scope of this course. diff --git a/Scala/md/ScalaCC.md b/Scala/md/ScalaCC.md index 8ca8319..04396e0 100644 --- a/Scala/md/ScalaCC.md +++ b/Scala/md/ScalaCC.md @@ -139,7 +139,7 @@ def linFun(m: Double, c: Double)(x: Double): Double = m*x + c val f = linFun(2, 3) -// f: Function1[Double, Double] = repl.MdocSession$MdocApp$$Lambda$8163/0x00000008020d8208@445113d1 +// f: Function1[Double, Double] = repl.MdocSession$MdocApp$$Lambda$8192/0x0000000802165e08@36ff03be f(0) // res22: Double = 3.0