summaryrefslogtreecommitdiff
path: root/lib/chessh/utils.ex
diff options
context:
space:
mode:
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