def insert_sublist_at(list, index, sublist):
    """
    Return the given list with the given sublist inserted at the given
    index.  If the index is one past the end, append the sublist.  If
    the index is otherwise out of bounds, return the list unmodified.
    """
    if index == 0:
        if sublist == ():
            return list
        else:
            subhead, subtail = sublist
            return (subhead, insert_sublist_at(list, index, subtail))
    elif list == ():
        return ()
    else:
        head, tail = list
        return (head, insert_sublist_at(tail, index - 1, sublist))