Skip to content

Commit e80e68e

Browse files
committed
remove fork-join
1 parent 1b77b91 commit e80e68e

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

_chapters/higherorderfunctions.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -462,26 +462,6 @@ Now we can try to find an id for each student, first from `class1` but fall back
462462
const ids = students.map(or(lookup(class1))(lookup(class2)))
463463
```
464464
465-
### Fork-Join Combinator
466-
467-
The following is cute:
468-
469-
```javascript
470-
function fork(join, f, g) {
471-
return value => join(f(value), g(value));
472-
}
473-
```
474-
475-
The `fork` function is a higher-order combinator that combines two functions, `f` and `g`, and then merges their results using a `join` function.
476-
477-
---
478-
479-
### Fork-Join Exercise
480-
481-
- Use the fork-join combinator to compute the average over a sequence of numeric values.
482-
483-
- Add type annotations to the above definition of the fork function. How many distinct type variables do you need?
484-
485465
#### Solutions
486466
487467
We can use the fork-join combinator by considering the sum and count of the sequence as the two branches (`f` and `g`), and then using a join function to divide the sum by the count to compute the average.

0 commit comments

Comments
 (0)