
-- seq(n)

create or replace function
	seq(n integer) returns setof integer
as $$
declare
	i integer;
begin
	for i in 1..n
	loop
		return next i;
	end loop;
end;
$$
language plpgsql;



-- seq(n,m)

create or replace function
	seq(lo integer, hi integer) returns setof integer
AS $function$
declare
	i integer;
begin
	for i in lo..hi
	loop
		return next i;
	end loop;
end;
$function$
language plpgsql;



-- seq(n,m,inc)

create or replace function
	seq(lo integer, hi integer, inc integer) returns setof integer
as $$
declare
	i integer;
begin
	i := lo;
	while i <= hi
	loop
		return next i;
		i := i + inc;
	end loop;
end;
$$
language plpgsql;

-- create or replace function seq(hi integer) returns setof integer
-- as $$
-- begin
-- 	return query select * from seq(1,hi,1);
-- end;
-- $$ language plpgsql;
