22 lines
439 B
Go
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 ""
|
||
|
}
|