You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose to add the function Backward to the package strings, as iterating over strings in reverse order is not trivial without allocating a new slice.
func Backward(s string) iter.Seq2[int, rune]
For now would it be:
// Returns a backwards iterator over bytes in s, yielding both the starting index and the rune.
func Backward(s string) iter.Seq2[int, rune]{
return func(yield func(int, rune) bool) {
for i := len(s); i > 0; {
r, size := utf8.DecodeLastRuneInString(s[0:i])
i -= size
if !yield(i, r) {
return
}
}
}
}
earthboundkid and ainar-gapparentlymart, fzipp, ericlagergren and seankhliao