Created
October 4, 2012 04:51
-
-
Save killerswan/3831538 to your computer and use it in GitHub Desktop.
These work for me on revision a35dc85...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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