mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
552 B
33 lines
552 B
4 years ago
|
## adding
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Create the function `add_curry` that returns a closure.
|
||
|
The purpose is to curry the add method to create more variations.
|
||
|
|
||
|
### Usage
|
||
|
|
||
|
Here is a program to test your function.
|
||
|
|
||
|
```rust
|
||
|
fn main() {
|
||
|
let add10 = add_curry(-10);
|
||
|
let add20 = add_curry(2066);
|
||
|
let add30 = add_curry(300000);
|
||
|
|
||
|
println!("{}", add10(5));
|
||
|
println!("{}", add20(195));
|
||
|
println!("{}", add30(5696));
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/[[ROOT]]/test$ cargo run
|
||
|
-5
|
||
|
2261
|
||
|
305696
|
||
|
student@ubuntu:~/[[ROOT]]/test$
|
||
|
```
|