Skip to content

Instantly share code, notes, and snippets.

@killerswan
Created October 4, 2012 04:51
Show Gist options
  • Save killerswan/3831538 to your computer and use it in GitHub Desktop.
Save killerswan/3831538 to your computer and use it in GitHub Desktop.
These work for me on revision a35dc85...
fn main() {
let mut v = [mut 1, 2,33,51,15,82,123,6,99, 52, 11, 5];
let mut max = 0;
(v).map(|i|{
if *i > max {
max = *i
}
io::print(fmt!("%d ", *i));
});
io::println(fmt!("max : %d", max));
let q = 2;
io::print(fmt!("%b", vec::contains(v,&q)));
max = 0;
v.each(fn&(i:&int) -> bool{
if *i > max {
max = *i;
}
io::print(#fmt("%d ", *i));
return true;
});
io::print(fmt!("max : %d", max));
io::println("\n");
}
fn main() {
let mut v = [mut 1, 2,33,51,15,82,123,6,99, 52, 11, 5];
let mut max = 0;
(v).map(|i|{
if *i > max {
max = *i
}
io::print(fmt!("%d ", *i));
});
io::println(fmt!("max : %d", max));
let q = 2;
io::print(fmt!("%b", vec::contains(v, &q)));
max = 0;
for vec::each(v)|i|{
if *i > max {
max = *i;
}
io::print(#fmt("%d ", *i));
}
io::print(fmt!("max : %d", max));
io::println("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment