rust/src/test/run-pass/iter-foldl.rs

10 lines
291 B
Rust
Raw Normal View History

2012-09-28 18:37:14 -05:00
fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) }
fn main() {
assert [1u, 3u]/_.foldl(20f, add) == 24f;
assert []/_.foldl(20f, add) == 20f;
2012-08-20 14:23:37 -05:00
assert None.foldl(20f, add) == 20f;
assert Some(1u).foldl(20f, add) == 21f;
assert Some(2u).foldl(20f, add) == 22f;
}