From db323908acc1b2730a3085a57a5d33389350e15f Mon Sep 17 00:00:00 2001 From: Howl Date: Sat, 28 May 2016 17:30:18 +0200 Subject: [PATCH] Add in.go --- common/in.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 common/in.go diff --git a/common/in.go b/common/in.go new file mode 100644 index 0000000..1ff46a7 --- /dev/null +++ b/common/in.go @@ -0,0 +1,13 @@ +package common + +// In picks x if y < x, picks z if y > z, or if none of the previous +// conditions is satisfies, it simply picks y. +func In(x, y, z int) { + switch { + case y < x: + return x + case y > z: + return z + } + return y +}