Skip to content

Commit

Permalink
Merge pull request #1560 from balroggg/refactor_fn_hof
Browse files Browse the repository at this point in the history
Change fold to sum in fn hof.md
  • Loading branch information
marioidival authored Jun 26, 2022
2 parents 81dbb3d + 3072303 commit 6026b8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fn/hof.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
(0..).map(|n| n * n) // All natural numbers squared
.take_while(|&n_squared| n_squared < upper) // Below upper limit
.filter(|&n_squared| is_odd(n_squared)) // That are odd
.fold(0, |acc, n_squared| acc + n_squared); // Sum them
.sum(); // Sum them
println!("functional style: {}", sum_of_squared_odd_numbers);
}
```
Expand Down

0 comments on commit 6026b8b

Please sign in to comment.