I had a pattern of numbers that repeats mod 72, so on a hunch I got the idea to use the following Python syntax:
for i in (x+t for x in range(k-k%72,80000000001,72) for t in (1,3,7,9,15,19,25,27,33,39,43,51,55,57,63)):
I think the first for
clause in the generator expression executes for one cycle, then the entire second one executes, then the next one in the first, then the entire second, etc., because the numbers come out in the correct order. It seems to produce the result I was looking for, but is this documented? I tried searching on Google with no conclusive results. Is it a feature, or am I just exploiting a quirk in Python? I know that if
clauses are allowed, but I didn't know that multiple for
clauses were too.
[Edit] Upon reading the link provided, I see I'm not the first to ask such a question. I also forgot that a generator expression and a list comprehension are essentially the same syntax, and so if I had tried "list comprehension" instead, maybe I'd have found it too.