Skip to content

Commit

Permalink
fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
johnazariah committed Dec 11, 2023
1 parent 41390c0 commit 4c06f88
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions _posts/2023-12-12-y-oh-y.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Here, `error` is a function that takes an argument and just throws an exception.
```fsharp
let fact0 = f (error)
fact0 0 // returns 1
fact0 1 // "goes Boom!"
fact0 1 // "0 goes Boom!"
```

Let us carefully understand why it works like this: `f error` (aka `fact0`) is a _function_ which takes a single integer argument and matches it against `0` (returning `1`), or _anything else_ (where it tries to multiply its argument with the result of `omega` invoked on the next smaller number).
Expand All @@ -108,7 +108,7 @@ Remember that `fact0`, just like `error`, is a function that takes a single argu
let fact1 = f fact0
fact1 0 // returns 1
fact1 1 // returns 1
fact1 2 // "goes Boom!"
fact1 2 // "0 goes Boom!"
```

And indeed, because we're on a roll here, let's go one further:
Expand All @@ -117,7 +117,7 @@ let fact2 = f fact1
fact2 0 // returns 1
fact2 1 // returns 1
fact2 2 // returns 2
fact2 3 // "goes Boom!"
fact2 3 // "0 goes Boom!"
```

I encourage you to actually try this to see that it _actually_ seems to be starting to calculate the factorial. Then come back and see if this explanation of _why_ it works is reasonable:
Expand Down

0 comments on commit 4c06f88

Please sign in to comment.