def _af_commutes_with(a, b):
 return (not any(((a[b[i]] != b[a[i]]) for i in range((len(a) - 1)))))

def _af_commutes_with ( a , b ) : return ( not any ( ( ( a [ b [ i ] ] != b [ a [ i ] ] ) for i in range ( ( len ( a ) - 1 ) ) ) ) )
checks if the two permutations with array forms given by a and b commute .