|
|
|
|
|
by simiones
862 days ago
|
|
You find func Backward[E any](s []E) func(func(int, E) bool) {
return func(yield func(int, E) bool) {
for i := len(s)-1; i >= 0; i-- {
if !yield(i, s[i]) {
return
}
}
}
}
simpler than C#'s IEnumerable<T> Backward(T[] s) {
for i := s.length-1; i >= 0; i-- {
yield return s[i];
}
}
I think that's quite hard to defend, honestly. Granted, Java doesn't have anything comparable, so I'm not sure what you're comparing this feature to. |
|