Lets assume I have defined function:
def threeArgs(x,y,z):
return ... # Returns True or False
I also have a list of elements:
a = [elem1, elem2, ..., elemN]
I would like to construct another list b containing first and last element form list a and those elements Xn in between for which threeArgs(Xn-1,Xn, Xn+1) returns true.
How to do it in elegant pythonic way?
Use slicing to create three shifted lists, then
zipthem together: