used to keep a number n between 0 and max, allowing for wraparounds
(n, max int)
| 37 | |
| 38 | // used to keep a number n between 0 and max, allowing for wraparounds |
| 39 | func ModuloWithWrap(n, max int) int { |
| 40 | if max == 0 { |
| 41 | return 0 |
| 42 | } |
| 43 | |
| 44 | if n >= max { |
| 45 | return n % max |
| 46 | } else if n < 0 { |
| 47 | return max + n |
| 48 | } |
| 49 | return n |
| 50 | } |
| 51 | |
| 52 | func FindStringSubmatch(str string, regexpStr string) (bool, []string) { |
| 53 | re := regexp.MustCompile(regexpStr) |
no outgoing calls