Skip to content

Commit 021b925

Browse files
committed
updates
1 parent d07e2af commit 021b925

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/main/scala/net/degoes/01-essentials/exercises.scala

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ object types {
110110
// EXERCISE 13
111111
//
112112
// Prove that `A + 0` is equivalent to `A` by implementing the following two
113-
// functions.
113+
// functions in a way that loses no information.
114114
//
115115
def to3[A](t: Either[A, Nothing]): A = ???
116116
def from3[A](a: A): Either[A, Nothing] = ???
@@ -335,7 +335,7 @@ object functions {
335335
def draw2(size: Int /* ... */ ): ??? = ???
336336
}
337337

338-
object higher_order {
338+
object parametric {
339339
//
340340
// EXERCISE 1
341341
//
@@ -399,11 +399,9 @@ object higher_order {
399399
else Right((input.drop(1), input.charAt(0)))
400400
)
401401
}
402-
}
403402

404-
object poly_functions {
405403
//
406-
// EXERCISE 1
404+
// EXERCISE 7
407405
//
408406
// Create a polymorphic function of two type parameters `A` and `B` called
409407
// `snd` that returns the second element out of any pair of `A` and `B`.
@@ -415,7 +413,7 @@ object poly_functions {
415413
snd((true, List(1, 2, 3))) // List(1, 2, 3)
416414

417415
//
418-
// EXERCISE 2
416+
// EXERCISE 8
419417
//
420418
// Create a polymorphic function called `repeat` that can take any
421419
// function `A => A`, and apply it repeatedly to a starting value
@@ -430,15 +428,15 @@ object poly_functions {
430428
repeat[Int => Int](100)(identity, _ andThen (_ + 1)) // (_ + 100)
431429

432430
//
433-
// EXERCISE 3
431+
// EXERCISE 9
434432
//
435433
// Count the number of unique implementations of the following method.
436434
//
437435
def countExample1[A, B](a: A, b: B): Either[A, B] = ???
438436
val countExample1Answer = ???
439437

440438
//
441-
// EXERCISE 4
439+
// EXERCISE 10
442440
//
443441
// Count the number of unique implementations of the following method.
444442
//
@@ -447,7 +445,7 @@ object poly_functions {
447445
val countExample2Answer = ???
448446

449447
//
450-
// EXERCISE 5
448+
// EXERCISE 11
451449
//
452450
// Implement the function `groupBy1`.
453451
//
@@ -472,7 +470,7 @@ object poly_functions {
472470
groupBy1(TestData, ByDate)(Reducer) == ExpectedResults
473471

474472
//
475-
// EXERCISE 6
473+
// EXERCISE 12
476474
//
477475
// Make the function `groupBy1` as polymorphic as possible and implement
478476
// the polymorphic function. Compare to the original.

0 commit comments

Comments
 (0)