def select_nth_last_of_type(cache, function, elem):
 (a, b) = function.parsed_arguments
 try:
  num = (cache.sibling_count(elem, before=False, same_type=True) + 1)
 except ValueError:
  return False
 if (a == 0):
  return (num == b)
 n = ((num - b) / a)
 return (n.is_integer() and (n > (-1)))

def select_nth_last_of_type ( cache , function , elem ) : ( a , b ) = function . parsed_arguments try : num = ( cache . sibling_count ( elem , before = False , same_type = True ) + 1 ) except ValueError : return False if ( a == 0 ) : return ( num == b ) n = ( ( num - b ) / a ) return ( n . is_integer ( ) and ( n > ( - 1 ) ) )
implement :nth-last-of-type() .