summaryrefslogtreecommitdiff
path: root/lib/chessh/utils.ex
diff options
context:
space:
mode:
authorSimponic <loganhunt@simponic.xyz>2023-01-13 10:00:58 -0700
committerSimponic <loganhunt@simponic.xyz>2023-01-13 10:00:58 -0700
commita93119b25033248decda7477575e214a1b254fbd (patch)
treee581569ca49b27251e7da64014eee13095625248 /lib/chessh/utils.ex
parentaa2ff6e1374e8a6a546aa04ee3430d1152c58553 (diff)
downloadchessh-a93119b25033248decda7477575e214a1b254fbd.tar.gz
chessh-a93119b25033248decda7477575e214a1b254fbd.zip
Binbo start link
Diffstat (limited to 'lib/chessh/utils.ex')
-rw-r--r--lib/chessh/utils.ex5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/chessh/utils.ex b/lib/chessh/utils.ex
index 3e83d5e..d1acf44 100644
--- a/lib/chessh/utils.ex
+++ b/lib/chessh/utils.ex
@@ -11,4 +11,9 @@ defmodule Chessh.Utils do
split = String.split(text, "\n")
{Enum.reduce(split, 0, fn x, acc -> max(acc, String.length(x)) end), length(split)}
end
+
+ def wrap_around(index, delta, length) do
+ calc = index + delta
+ if(calc < 0, do: length, else: 0) + rem(calc, length)
+ end
end