use std::option;
use std::os;
use std::task;
+use std::vec_ng::Vec;
fn print_complements() {
let all = [Blue, Red, Yellow];
}
}
-fn show_color_list(set: vec!(color)) -> ~str {
+fn show_color_list(set: Vec<color>) -> ~str {
let mut out = ~"";
for col in set.iter() {
out.push_char(' ');
}
}
-fn rendezvous(nn: uint, set: vec!(color)) {
+fn rendezvous(nn: uint, set: Vec<color>) {
// these ports will allow us to hear from the creatures
let (to_rendezvous, from_creatures) = channel::<CreatureInfo>();
// these channels will be passed to the creatures so they can talk to us
// these channels will allow us to talk to each creature by 'name'/index
- let to_creature: Vec<Sender<Option<CreatureInfo>>> =
+ let mut to_creature: Vec<Sender<Option<CreatureInfo>>> =
set.iter().enumerate().map(|(ii, col)| {
// create each creature as a listener with a port, and
// give us a channel to talk to each
// set up meetings...
for _ in range(0, nn) {
- let fst_creature: CreatureInfo = from_creatures.recv();
- let snd_creature: CreatureInfo = from_creatures.recv();
+ let mut fst_creature: CreatureInfo = from_creatures.recv();
+ let mut snd_creature: CreatureInfo = from_creatures.recv();
creatures_met += 2;
- to_creature[fst_creature.name].send(Some(snd_creature));
- to_creature[snd_creature.name].send(Some(fst_creature));
+ to_creature.get_mut(fst_creature.name).send(Some(snd_creature));
+ to_creature.get_mut(snd_creature.name).send(Some(fst_creature));
}
// tell each creature to stop
} else if args.len() <= 1u {
vec!(~"", ~"600")
} else {
- args
+ args.move_iter().collect()
};
- let nn = from_str::<uint>(args[1]).unwrap();
+ let nn = from_str::<uint>(*args.get(1)).unwrap();
print_complements();
println!("");