Jump to content

Currying: Difference between revisions

128 bytes removed ,  7 years ago
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 1,158:
 
This is a simple currying function written in [[Rust]]:
<lang rust>#![feature(box_syntaxconservative_impl_trait)]
fn add_n<'a>(n : i32) -> Box<impl Fn(i32) -> i32 + 'static> a {
box move |&: x| n + x
}
 
Line 1,167:
println!("The answer to life is {}.", adder(2));
}</lang>
 
Note that once "unboxed, abstract return types" are supported it can be done without the heap allocation/trait object indirection.
 
=={{header|Scala}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.