def set_generator(random, args):
    """
    Generates a list containing non-repeated elements of a discrete or
    continuous representation.

    Parameters
    ----------

    random : Random
    args : dict
        representation: set containing the possible values
        max_candidate_size: int, default: 9
        variable_candidate_size: bool, default: True


    Returns
    -------
    list
        A list containing a sample of the elements. If variable_candidate_size is
        True the list size is up to max_candidate_size, otherwise the candidate
        size equals candidate_size
    """
    representation = args.get('representation')
    indices = list(range(len(representation)))
    max_size = args.get('max_size', 9)
    variable_size = args.get('variable_size', True)
    if variable_size and max_size > 1:
        size = random.randint(1, max_size)
    else:
        size = max_size
    candidate = random.sample(indices, size)
    return sorted(candidate)