Hi, how would you solve problem like: Find if ther...
# getting-started
z
Hi, how would you solve problem like: Find if there are several (reps) SUBSEQUENT elements in iterable holding some condition? I used fold:
Copy code
slots.fold(
                        0,
                        {i, slot ->
                            if(i>reps-1){
                                i // once it happened
                            } else
                                if(slot.card!=null){ // condition
                                    i+1  // in row
                                }else{
                                    0  // reset
                                }
                        }
                )  > rep-1
I do on very small sets but.. it is not obviously not very efficient.. would you recommend idiomatic yet effective way?