From bd7cc5ce68bd9e573d22790e1c65851a848ef9f2 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Wed, 12 Dec 2018 15:06:59 -0500 Subject: [PATCH] Add a simple absolute value function. --- 2018/internal/util/math.go | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 2018/internal/util/math.go diff --git a/2018/internal/util/math.go b/2018/internal/util/math.go new file mode 100644 index 0000000..a3bf4bc --- /dev/null +++ b/2018/internal/util/math.go @@ -0,0 +1,8 @@ +package util + +func abs(x int) int { + if x < 0 { + return -x + } + return x +}