From dc7853ec7cf4de1e33b276e38fc283b0002d9703 Mon Sep 17 00:00:00 2001 From: Xavier Petit <32063953+xpetit@users.noreply.github.com> Date: Mon, 11 May 2020 22:14:58 +0200 Subject: [PATCH] Move useful code --- go/{tests/common => lib/is}/is.go | 2 +- go/tests/any/main.go | 8 ++++---- go/tests/countif/main.go | 8 ++++---- go/tests/isnumeric/main.go | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) rename go/{tests/common => lib/is}/is.go (93%) diff --git a/go/tests/common/is.go b/go/lib/is/is.go similarity index 93% rename from go/tests/common/is.go rename to go/lib/is/is.go index af9acc50b..44dd64a32 100644 --- a/go/tests/common/is.go +++ b/go/lib/is/is.go @@ -5,7 +5,7 @@ import ( "unicode" ) -func IsNumeric(s string) bool { +func IsDigit(s string) bool { for _, r := range s { if !unicode.IsDigit(r) { return false diff --git a/go/tests/any/main.go b/go/tests/any/main.go index fa08b724d..18f0ef983 100644 --- a/go/tests/any/main.go +++ b/go/tests/any/main.go @@ -17,7 +17,7 @@ func any(f func(string) bool, arr []string) bool { } func main() { - functions := []func(string) bool{common.IsNumeric, common.IsLower, common.IsUpper} + functions := []func(string) bool{common.IsDigit, common.IsLower, common.IsUpper} type node struct { f func(string) bool @@ -35,7 +35,7 @@ func main() { } for i := 0; i < 5; i++ { table = append(table, node{ - f: common.IsNumeric, + f: common.IsDigit, a: lib.MultRandDigit(), }) } @@ -55,11 +55,11 @@ func main() { table = append(table, node{ - f: common.IsNumeric, + f: common.IsDigit, a: []string{"Hello", "how", "are", "you"}, }, node{ - f: common.IsNumeric, + f: common.IsDigit, a: []string{"This", "is", "4", "you"}, }, ) diff --git a/go/tests/countif/main.go b/go/tests/countif/main.go index f3642f669..8017fe252 100644 --- a/go/tests/countif/main.go +++ b/go/tests/countif/main.go @@ -18,7 +18,7 @@ func countIf(f func(string) bool, arr []string) int { } func main() { - functions := []func(string) bool{common.IsNumeric, common.IsLower, common.IsUpper} + functions := []func(string) bool{common.IsDigit, common.IsLower, common.IsUpper} type node struct { f func(string) bool @@ -37,7 +37,7 @@ func main() { } for i := 0; i < 5; i++ { val := node{ - f: common.IsNumeric, + f: common.IsDigit, arr: lib.MultRandDigit(), } table = append(table, val) @@ -60,11 +60,11 @@ func main() { table = append(table, node{ - f: common.IsNumeric, + f: common.IsDigit, arr: []string{"Hello", "how", "are", "you"}, }, node{ - f: common.IsNumeric, + f: common.IsDigit, arr: []string{"This", "is", "4", "you"}, }, ) diff --git a/go/tests/isnumeric/main.go b/go/tests/isnumeric/main.go index 2e5b39255..3d3b43280 100644 --- a/go/tests/isnumeric/main.go +++ b/go/tests/isnumeric/main.go @@ -33,6 +33,6 @@ func main() { "01,02,03", ) for _, arg := range table { - lib.Challenge("IsNumeric", student.IsNumeric, common.IsNumeric, arg) + lib.Challenge("IsNumeric", student.IsNumeric, common.IsDigit, arg) } }