You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(unboxed_closures)]fntarai<F:Fn() -> i32>(x:i32,y:i32,z:F) -> i32{if x <= y {
y
}else{let fz = z();let nx = tarai(x - 1, y, z);let ny = tarai(y - 1, fz, |&:| { x });let nz = |&:| {tarai(fz - 1, x, |&:| { y })};tarai(nx, ny, nz)}}fnmain(){println!("{}", tarai(12,6, |&:| {0}));}
but compiling this code, occurs an error like this:
$ rustc ./21-161505.rs
21-161505.rs:3:1: 15:2 error: reached the recursion limit during monomorphization
21-161505.rs:3 fn tarai<F:Fn() -> i32>(x:i32, y:i32, z:F) -> i32 {
21-161505.rs:4 if x <= y {
21-161505.rs:5 y
21-161505.rs:6 }
21-161505.rs:7 else {
21-161505.rs:8 let fz = z();
...
Why my code is wrong? And what should I do for pass compiling without errors?
Please show me these. Sorry for poor my english. Thank you.
The text was updated successfully, but these errors were encountered:
hebiyan
changed the title
"reached the recursion limit dureing monomorphization" error occured
"reached the recursion limit during monomorphization" error occured
Jan 21, 2015
I tried writing tarai function with Rust, version info is:
written code is:
but compiling this code, occurs an error like this:
Why my code is wrong? And what should I do for pass compiling without errors?
Please show me these. Sorry for poor my english. Thank you.
The text was updated successfully, but these errors were encountered: