Is there a functional style of doing a do while (s...
# announcements
l
Is there a functional style of doing a do while (so that I don't have to create a variable before entering loop)? Basically I have an array and I generate a new array with 1 less element, when no more elements or the array is in the desired state the loop is done.
it uses the previous array to generate the new one
s
What about using the
.filter { … }
operator on a list?
l
not sure what you mean, how would it work?
oh maybe it can work. if I do (1...sizeOfArray).filter { calculate and return 0 }. but I can't exit early
and can't pass new array to next calculation
recursion is probably only way
1
j
some example code might help to see what you're trying to do
☝️ 1
s
There are
takeUntil
and
takeWhile
operators as well.