Currying: Difference between revisions
Content added Content deleted
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
|||
Line 1,158: | Line 1,158: | ||
This is a simple currying function written in [[Rust]]: |
This is a simple currying function written in [[Rust]]: |
||
<lang rust>#![feature( |
<lang rust>#![feature(conservative_impl_trait)] |
||
fn add_n(n : i32) -> |
fn add_n<'a>(n : i32) -> impl Fn(i32) -> i32 + 'a { |
||
move |x| n + x |
|||
} |
} |
||
Line 1,167: | Line 1,167: | ||
println!("The answer to life is {}.", adder(2)); |
println!("The answer to life is {}.", adder(2)); |
||
}</lang> |
}</lang> |
||
Note that once "unboxed, abstract return types" are supported it can be done without the heap allocation/trait object indirection. |
|||
=={{header|Scala}}== |
=={{header|Scala}}== |