public/subjects/adding/README.md

35 lines
517 B
Markdown
Raw Permalink Normal View History

2020-12-29 10:40:42 +00:00
## adding
### Instructions
2022-06-14 21:24:15 +00:00
Create the function `add_curry`, which returns a closure.
The purpose is to 'curry' the add method to create more variations.
2020-12-29 10:40:42 +00:00
### Usage
Here is a program to test your function.
```rust
2021-03-10 04:18:44 +00:00
use adding::add_curry;
2020-12-29 14:38:26 +00:00
2020-12-29 10:40:42 +00:00
fn main() {
let add10 = add_curry(-10);
let add20 = add_curry(2066);
let add30 = add_curry(300000);
2021-03-10 04:18:44 +00:00
2020-12-29 10:40:42 +00:00
println!("{}", add10(5));
println!("{}", add20(195));
println!("{}", add30(5696));
}
```
2021-03-10 04:18:44 +00:00
And its output:
2020-12-29 10:40:42 +00:00
```console
$ cargo run
2020-12-29 10:40:42 +00:00
-5
2261
305696
$
2020-12-29 10:40:42 +00:00
```