Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Rust

Name: Anonymous 2015-01-20 22:27

Name: Anonymous 2015-01-22 2:16

Just look at this shit.

use std::cell::Cell;

fn a(k: i32,
x1: &Fn() -> i32,
x2: &Fn() -> i32,
x3: &Fn() -> i32,
x4: &Fn() -> i32,
x5: &Fn() -> i32) -> i32 {
let k = Cell::new(k);

let b: Cell<Option<&Fn() -> i32>> = Cell::new(None);
let tmp = |&:| {
k.set(k.get() - 1);
a(k.get(), &*b.get().unwrap(), x1, x2, x3, x4)
};
b.set(Some(&tmp));

if k.get() <= 0 { x4() + x5() } else { b.get().unwrap()() }
}

fn main() {
println!("%{}", a(10, &|| 1, &|| -1, &|| -1, &|| 1, &|| 0));
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List