Skip to content

Commit

Permalink
Change fold to sum
Browse files Browse the repository at this point in the history
  • Loading branch information
balroggg committed Jun 25, 2022
1 parent 81dbb3d commit 3072303
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 3072303

Please sign in to comment.