Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created March 5, 2012 05:28
Show Gist options
  • Save nikomatsakis/1976872 to your computer and use it in GitHub Desktop.
Save nikomatsakis/1976872 to your computer and use it in GitHub Desktop.

Running this program:

use std;
import std::io;

fn iter(&&v: [uint], f: fn(uint)) {
    for i in v { f(i) }
}

fn main(args: [str]) {
    let v = vec::enum_uints(0u, 10u);
    iter(v) { |i|
         v = [];
         io::print(#fmt["i=%?\n", i]);
    }
}

yields this output

i=0
i=2
i=171048973
i=1979117988610105
i=4122818071364057393
i=3978138846657458487
i=3979273541751617588
i=51
i=17293822612877934602
i=17293822569102704640
i=9

Hmm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment