Skip to content

Commit

Permalink
fixup! #21 Add TakeLastWhile implements
Browse files Browse the repository at this point in the history
  • Loading branch information
meian committed Feb 5, 2022
1 parent e3b4317 commit b2a225f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions take_last.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ func (it *takeLastWhileIterator[T]) build() {
s := iteratorToSlice(it.it)
if !it.whileFunc(s[len(s)-1]) {
it.it = emptyIter[T]()
} else {
for i := len(s) - 2; i >= 0; i-- {
if !it.whileFunc(s[i]) {
s = s[i+1:]
break
}
it.built = true
return
}
for i := len(s) - 2; i >= 0; i-- {
if !it.whileFunc(s[i]) {
s = s[i+1:]
break
}
it.it = makeSliceIterator(s)
}
it.it = makeSliceIterator(s)
it.built = true
}

0 comments on commit b2a225f

Please sign in to comment.