exercism/go/series/slice.go
2016-08-13 18:20:14 -05:00

22 lines
439 B
Go

package slice
// All takes a string 'str' and a length 'l' and returns
// all substrings of length l
func All(l int, str string) []string {
var ret []string
for len(str) >= l {
ret = append(ret, str[:l])
str = str[1:]
}
return ret
}
// Frist (Frist?!) takes a string 'str' and a length 'l' and returns
// the first substring of length l
func Frist(l int, str string) string {
if len(str) >= l {
return str[:l]
}
return ""
}