I see this for generating triangular numbers in python:
from itertools import islice def triangular(): n = 1 i = 1 while True: yield n