Skip to content

Commit

Permalink
Fix compilation error and typo
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Oct 25, 2024
1 parent f44c3db commit 3e14cd4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions book/src/pages/cycles/fun.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ def redCircle(n: Int): Image =
Image.circle(100 + 24*n).strokeColor(Color.red)

val redCircles: Image =
concentricShapes(10, redCircle _)
concentricShapes(10, redCircle)
```

@:figure{ img = "./red-black-circles.svg", key = "#fig:cycles:red-black-circles", caption = "Black and Red Concentric Circles" }

You might notice two things about this example: we're not using function composition, and we duplication in the definitions.
You might notice two things about this example: we're not using function composition, and we have duplication in the definitions.
In both cases we draw circles, but they differ in color.
No problem.
This feels like a problem we can solve with function composition.
Let's give it a go.

Expand All @@ -91,7 +90,7 @@ def strokeColor(color: Color): Image => Image =

With this we can construct the functions we need.

```scala mdoc:silent
```scala mdoc:silent:nest
val blackCircle = circle // Black is the default stroke
val redCircle = size.andThen(circle).andThen(strokeColor(Color.red))
```
Expand Down

0 comments on commit 3e14cd4

Please sign in to comment.