interval(Low, High, [High]) :- Low = High.
interval(Low, High, [Low|Tail]) :- 
	NewLow is Low + 1, interval(NewLow, High, Tail).

make_interval(Low, High, i(Low, High)) :- integer(Low), integer(High).
interval_done(i(Low, High)) :- Low > High.
interval_next(Low, i(Low,High), i(Low1,High)) :- 
	plus(Low, 1, Low1), Low =< High.

enum_interval(Low, High, X) :-
	integer(Low),
	integer(High),
	(   var(X) ->
	    Low =< High,
	    enum_interval1(Low, High, X)
	;   integer(X) ->
	    Low =< X,
	    X =< High
	).

enum_interval1(L, U, L).
enum_interval1(L, U, X) :- L < U, M is L + 1, enum_interval1(M, U, X).