Skip to content

Commit 0a5cf6e

Browse files
EliasBinders-m-i-t-a
authored andcommitted
Refactoring of matrix helper, cleanup
1 parent 15c139d commit 0a5cf6e

File tree

3 files changed

+236
-10
lines changed

3 files changed

+236
-10
lines changed

.tool-versions

Lines changed: 0 additions & 2 deletions
This file was deleted.

hello.svg

Lines changed: 234 additions & 0 deletions
Loading

lib/qr_code/matrix_helper.ex

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ defmodule QRCode.MatrixHelper do
1111
# Create new matrix with quiet zone
1212
{:ok, new_matrix} = Matrix.new({rows + 2 * quiet_zone, cols + 2 * quiet_zone}, value)
1313

14-
# Copy matrix to new matrix
15-
new_matrix = Enum.reduce(0..rows - 1, new_matrix, fn row, acc_matrix ->
16-
Enum.reduce(0..cols - 1, acc_matrix, fn col, acc_matrix_inner ->
17-
{:ok, element} = Matrix.get_element(matrix, {row, col})
18-
{:ok, updated_matrix} = Matrix.update_element(acc_matrix_inner, element, {row + quiet_zone, col + quiet_zone})
19-
updated_matrix
20-
end)
21-
end)
14+
# Copy qr code matrix to new matrix
15+
{:ok, new_matrix} = Matrix.update_map(new_matrix, matrix, [{quiet_zone, quiet_zone}])
2216

2317
new_matrix
2418
end

0 commit comments

Comments
 (0)