File: utils.go

package info (click to toggle)
golang-github-abadojack-whatlanggo 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 444 kB
  • sloc: makefile: 2
file content (19 lines) | stat: -rw-r--r-- 362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package whatlanggo

import "unicode"

//isStopChar returns true if r is space, punctuation or digit.
func isStopChar(r rune) bool {
	if unicode.IsSymbol(r) || unicode.IsSpace(r) || unicode.IsPunct(r) || unicode.IsDigit(r) {
		return true
	}
	return false
}

//abs returns the absolute value of x.
func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}