Imperative vs Declarative
Declarative programs we are describing what to do, rather than how to do it.

Imperative

1
let mut sum = 0;
2
for i in 1..11 {
3
sum += i;
4
}
5
println!("{}", sum);
Copied!

Declarative

Imperative

1
let mut sum = 0;
2
for i in 1..11 {
3
sum += i;
4
}
5
println!("{}", sum);
Copied!

Declarative

Declarative programs we are describing what to do, rather than how to do it.
1
println!("{}", (1..11).fold(0, |a, b| a + b));
Copied!
Copy link
Edit on GitHub