Moving maximums

x mmax y    mmax[x;y]

Where

returns the x-item moving maximums of y, with nulls after the first replaced by the preceding maximum. The first x items of the result are the maximums of the items so far, and thereafter the result is the moving maximum.

q)3 mmax 2 7 1 3 5 2 8
2 7 7 7 5 5 8
q)3 mmax 0N -3 -2 0N 1 0  / initial null returns negative infinity
-0W -3 -2 -2 1 1          / remaining nulls replaced by preceding max

mmax is a uniform function.