From 1c82d1716aea120d26f9988edea5a9b4e62dffe0 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Sun, 23 Feb 2020 14:36:55 +0100 Subject: [PATCH] Use CartesianIndices instead of handmade tuples --- src/mcmc.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mcmc.jl b/src/mcmc.jl index 2f9758c..343ed8e 100644 --- a/src/mcmc.jl +++ b/src/mcmc.jl @@ -22,9 +22,7 @@ end "Return the neighbours to be filled of the cell at the given index." function neighbours(garden::Matrix{Int}, idx::Int)::Vector{Int} m, n = size(garden) - j, i = divrem(idx - 1, m) - i += 1 - j += 1 + i, j = Tuple(CartesianIndices(garden)[idx]) neighbourindices = [(i, j-1), (i, j+1), (i-1, j), (i+1, j)] # cells filled with 0 are not part of the garden [