You can curry things, if you want, but it isn't done automatically. If you want 
to create one argument functions that return one argument functions, you need 
to do that explicitly. 

I'm not totally sure what you were trying to do with your example, but here is 
something similar (I think):


fn applyn(n: int) -> fn@(fn@(i: int)) {
    return |f| {
        let mut i = 0;
        while i < n {
          f(i);
          i += 1;
        }
    };
}

fn main() {
    let apply10 = applyn(10);
    apply10(|i| { io::println(i.to_str()); });
}

On Oct 25, 2012, at 7:04 PM, Amitava Shee wrote:

> fn printn(n: int, f:fn@(i: int)) {
>   let mut i = 0;
>   while i < n {
>     f(i)
>   }
> }
> 
> fn main() {
>   let print10: fn@(i:int) = printn(10, _);  // does not compile 
> }

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to