Crates.io | sandpile |
lib.rs | sandpile |
version | 0.1.0 |
source | src |
created_at | 2017-01-18 16:31:14.892732 |
updated_at | 2017-01-18 16:31:14.892732 |
description | Library to do sandpile computations |
homepage | |
repository | https://github.com/chinmaydd/sandpile |
max_upload_size | |
id | 8125 |
size | 7,751 |
Sandpile implementation in Rust. WIP.
extern crate sandpile;
use sandpile::Sandpile;
fn main() {
let rows = 3;
let cols = 3;
// Create a new sandpile.
let a = Sandpile::new(rows, cols, Some(vec![1,2,3,1,2,3,1,2,3]));
// Create another sandpile.
// Since no initialization data is provided,
// the sandpile will be populated with 0s
let b = Sandpile::new(rows, cols, None);
// We have overloaded the '+' operator for sandpiles.
let c = a + b;
println!("{}", c);
}
/*
Output:
1 | 2 | 3 |
1 | 2 | 3 |
1 | 2 | 3 |
*/
MIT