Hi I have this piece of code and trying to refactor it to be declarative. But AFAIK, all declarative methods like map() reduce() filter() will loop through each element of the container, not a few like this
def arrayCheck(nums):
# Note: iterate with length-2, so can use i+1 and i+2 in the loop
for i in range(len(nums)-2):
# Check in sets of 3 if we have 1,2,3 in a row
if nums[i]==1 and nums[i+1]==2 and nums[i+2]==3:
return True
return False
So how to write this code, declarative way?