I have the feeling that you're looking for a more stateless solution. Let me redecorate the existing solution in that style:
// entry action; can start at any point in list
test(initial_stamp)
// recursive transit of list
// will either error, or exit due to EndOfList
function test(current)
next := nextmarker(current)
if next - current > FifteenMinutes then
error
else
test(next)
endif
endfunc
// get next 15m marker
// returns marker or exits due to EndOfList
function nextmarker(stamp)
check_stamp := stamp.next
if check_stamp == EndOfList
exit
if check_stamp MOD FifteenMinutes <> 0 then
return nextmarker(check_stamp)
else
return check_stamp
endif
endfunc
TonyC got after me about wasting RAM on the recursion, so:
function test(current)
next := nextmarker(current)
while next - current <= FifteenMinutes do
current := next
next := nextmarker(current)
done
error
endfunc