def saveResult(timer, currentAttribute, totalAttribute, currentResult):
    """ 
    Save the current result in currentAttribute and append to totalAttribute 
    
    Parameters
    ----------
    timer : Timer instance
        Pointer to the common timer instance
    currentAttribute : Array-like
        Attribute for the results of the current optimization period
    totalAttribute : Array-like
        Attribute for the results of all optimization periods
    currentResult : Array-like
        Results of the current optimization period
        
    Returns
    -------
    Returns a tuple of updated currentAttribute and totalAttribute
    
    Examples
    --------
    >>> # Save the results of a scheduling optimization
    >>> # Due to limited space, the variable names are shortened
    >>> # cS --> current_device_schedule, tS --> total_device_schedule
    >>> schedule = optimizer(...)
    >>> (self.cS, self.tS) = saveResult(timer, self.cS, self.tS, schedule)
    """
    # Get current and final position
    currentPosition = timer.current_timestep
    finalPosition = currentPosition + timer.timesteps_used_horizon
    
    # Only save the first values that are not overwritten later
    requiredResult = currentResult[0:timer.timesteps_used_horizon]
    
    # Save the results
    currentAttribute = requiredResult
    totalAttribute[currentPosition:finalPosition] = requiredResult
    
    return (currentAttribute, totalAttribute)