def rhs_remove(rhs, sublist):
  """Remove occurrences of sublist in rhs."""
  new_list = []
  idx = 0
  if len(sublist) > len(rhs):
    return new_list
  while idx < len(rhs):
    if rhs[idx:idx + len(sublist)] == sublist:
      idx += len(sublist)
    else:
      new_list.append(rhs[idx])
      idx += 1
  return new_list
Remove occurrences of sublist in rhs.
language/compgen/csl/induction/rule_utils.py