Created
November 1, 2012 01:32
-
-
Save psyomn/3991057 to your computer and use it in GitHub Desktop.
Circlejerking with Rust
This file contains 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
/** | |
test comments | |
*/ | |
fn main() | |
{ | |
io::println("HELLO WORLD"); | |
let x: int = add_numbers(12,21); | |
io::println(fmt!("Add numbers function : %d" , x)); | |
io::println(fmt!("Cound and add numbers : %?" , count_and_add_numbers(10))); | |
call_later(); | |
nice_for(); | |
return; | |
} | |
fn call_later() | |
{ | |
io::println("You called this from a function"); | |
} | |
fn add_numbers(num1: int, num2: int) -> int | |
{ | |
return num1 + num2; | |
} | |
fn count_and_add_numbers(num : int) -> int | |
{ | |
let mut accumulator: int = 0; | |
let mut counter: int = num; | |
while counter > 0 | |
{ | |
accumulator += counter; | |
counter -= 1; | |
} | |
return accumulator; | |
} | |
fn nice_for() | |
{ | |
for ["hello", "there", "francis"].each |text| { | |
io::println(fmt!("%?", text)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment