Skip to content

Instantly share code, notes, and snippets.

@deontologician
Created April 13, 2014 03:27
Show Gist options
  • Save deontologician/10567861 to your computer and use it in GitHub Desktop.
Save deontologician/10567861 to your computer and use it in GitHub Desktop.
fn main() {
let mut rows = [[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9,10,11,12],
[13,14,15,16]];
for i in range(0, 4u) {
for j in range(0, 3u) {
/// Here's what I'd like to do
if rows[i][j+1] == 0 {
rows[i][j+1] = rows[i][j];
rows[i][j] = 0;
}
/// Is there a way to pull that out into a function called like:
combine(&mut rows[i][j], &mut rows[i][j+1]);
}
println!("\n------------");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment