After Effects: Increment a Variable over time
You can loop over the range of frames from the start of the comp to the present and calculate the value along the way.

function myFuncf(theTime){
 //whatever the function you're using to create the value, e.g.
 t=theTime + s.valueAtTime(theTime); //s is the slider
 return t
}

firstFrame = timeToFrames(inPoint); //if you want it to calculate
                                    //from the beginning of the comp
                                    //change this to 0, or maybe 1?
                                    //I'd check but I'm rendering ATM

mytime=0; //initialise the mytime variable

currentFrame = timeToFrames(time);
for (int i=firstFrame; i &lt;= currentFrame; i++){
  mytime += myFunc(framesToTime(i)); //need to convert frames back into seconds
}


after the loop myTime should be the sum of the results of function myFunc from all the previous frames up to and including the present one (I'm not 100% sure if the loop should end when i &lt; cf or i &lt;= cf, you might want to test).

note first time I posted this there was a mistake. Where I called the function I was giving it frames (from i the loop variable), but it uses valueAtTime which expects time in seconds, so you need to convert: mytime += myFunc(framesToTime(i));

If you have a long comp or this is applied to lots of layers, this expression may become slow to evaluate and cause lagginess. If it becomes a problem convert the expression to keyframes.