Skip to content

Instantly share code, notes, and snippets.

@eholk
Created February 2, 2012 06:09
Show Gist options
  • Select an option

  • Save eholk/1721833 to your computer and use it in GitHub Desktop.

Select an option

Save eholk/1721833 to your computer and use it in GitHub Desktop.
use std;
iface vector {
fn [](i: uint) -> float;
fn len() -> uint;
}
impl vector_utils for vector {
fn print() {
std::io::print("[ ");
self.each() {|x|
std::io::print(float::to_str(x, 10u) + " ");
};
std::io::println("]");
}
fn each(f: fn(float)) {
uint::range(0u, self.len()) {|i|
f(*@self[i])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment