From 5d39610f11f1c5292fe6b91249c267a8d4e3540f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 23 Mar 2022 20:46:14 +0800 Subject: [PATCH] refactor: use % --- src/maze/_impl/_mz_square_cells_impl.scad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/maze/_impl/_mz_square_cells_impl.scad b/src/maze/_impl/_mz_square_cells_impl.scad index 67807bfc..bfd185f0 100644 --- a/src/maze/_impl/_mz_square_cells_impl.scad +++ b/src/maze/_impl/_mz_square_cells_impl.scad @@ -53,13 +53,13 @@ function rand_dirs(c, seed) = _next_x_table = [1, 0, -1, 0]; function next_x(x, dir, columns, wrapping) = let(nx = x + _next_x_table[dir]) - wrapping ? (nx < 0 ? nx + columns : nx % columns) : nx; + wrapping ? (nx + columns) % columns : nx; // get y value by dir _next_y_table = [0, 1, 0, -1]; function next_y(y, dir, rows, wrapping) = let(ny = y + _next_y_table[dir]) - wrapping ? (ny < 0 ? ny + rows : ny % rows) : ny; + wrapping ? (ny + rows) % rows : ny; // go right and carve the right wall function carve_right(x, y, cells) =