Given a cumulative function f, is it possible to define an integer expression that would maintain the maximum of f ?

I do not see how to do that using expressions such as

dexpr int h = heightAtStart(a,f[,dval]);

since this would maintain h as the value of the cumulative function at the start of interval a

The only trick I can see would to define a set of consecutive intervals of size 1, let's say a[1..100] and using dexpr int h[i in 1..100] = heightAtStart(a[i],f), we could then compute dexpr int maxh = max(i in 1..100) h[i] , but that is probably not efficient since we discretize time...