def replace_sublist(li, target, replacement):
    """
  Replace a sublist with another sublist.
  Not very effcient.
  If 'eq' is given, this will be used to compare items.
  """
    result = []
    i = 0
    while i < len(li):
        if li[i:i + len(target)] == target:
            i += len(target)
            result.extend(replacement)
        else:
            result.append(li[i])
            i += 1
    return result
