diff options
author | rsiddharth <s@ricketyspace.net> | 2020-09-05 19:06:21 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-09-05 19:06:21 -0400 |
commit | d20fdad72c7ff1b1b6ee1623626c16ea50284745 (patch) | |
tree | 65f0c0371f9c2d1dddb0dc9648fd57ac54713d7c /lib | |
parent | 2d9992587c8914050ba1f1f71345836c116ea14a (diff) |
lib: add AlphaScore
* lib/str.go (AlphaScore): New function.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/str.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -29,6 +29,16 @@ func stripSpaceChars(s string) string { return ss } +func AlphaScore(bs []byte) int { + s := 0 + for i := 0; i < len(bs); i++ { + if isAlpha(bs[i]) { + s += 1 + } + } + return s +} + func isAlpha(c byte) bool { switch { case 'A' <= c && c <= 'Z': |