docs(course): fix review findings in modules 00–05

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-29 01:04:03 +01:00
co-authored by Claude Opus 5.5
parent 1d0b8c3a5c
commit ab8abaaa77
4 changed files with 66 additions and 7 deletions
@@ -541,6 +541,20 @@ It is "the value of `nextUint32`, transformed". Which of your new functions tran
</details>
<details><summary>Exercise 4.3 (intBelow) — near-solution (try the others first)</summary>
```js
export const intBelow = (n) => map(___, (v) => ___)
```
```scala
def intBelow(n: Int): Random[Int] = nextUint32.map(v => ___)
```
```fsharp
let intBelow (n: int) : Random<int> = nextUint32 |> map (fun v -> ___)
```
</details>
<details><summary>Exercise 4.4 (freeCells) — nudge</summary>
First build *all* cells in row-major order, then keep those not in the snake.
@@ -615,6 +629,23 @@ Each is one line: a function applied to the result of another.
</details>
<details><summary>Exercise 4.6 (tick, newGame) — near-solution (try the others first)</summary>
```js
export const tick = (state) => spawnApple(___(state))
export const newGame = (seed) => ___(initialState(___))
```
```scala
def tick(state: GameState): GameState = spawnApple(___)
def newGame(seed: Long): GameState = ___(Model.initialState(___))
```
```fsharp
let tick (state: GameState) : GameState = state |> Rules.advance |> ___
let newGame (seed: uint32) : GameState = seed |> ___ |> ___
```
</details>
## Check your understanding
1. Why is `const roll = () => Math.floor(Math.random() * 6)` impure, while `d6 = map(nextUint32, v => 1 + v % 6)` is pure? Where did the "randomness" go?