Repeat X times recursively

I want to create a snippet that generates 52 dates one week apart. I've accomplished this rather inelegantly with the code below. Is there a simpler way to do this? Surely I should be able to list a range of numbers as opposed to each integer individually, or use the repeat function recursively to create a list of integers, along the lines of {repeat: for x in [{x=x+1}]}.

{repeat: for x in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]}{time: MMMM Do, YYYY; shift={=7*x}D}, {endrepeat}

Hey @Brandt_Weary, I see you're diving into the esoteria of Text Blaze hehehe.

Something like this maybe?

{list=seq(0,52)}
{repeat: for x in list}{time: MMMM Do, YYYY; shift={=7*x}D}, {endrepeat}

And this gives you one entry per line:

{list=seq(0,52)}
{repeat: for x in list; trim=right}
{time: MMMM Do, YYYY; shift={=7*x}D}
{endrepeat}

I'm using the trim setting for the sake of legibility.

And with this one you can get the sequence starting from a set date (cos I know where your mind's at :grin:):

{list=seq(0,52)}
{formdate: YYYY-MM-DD; name=date}
{repeat: for x in list; trim=right}
{time: MMMM Do, YYYY; at={=date}; pattern=YYYY-MM-DD; shift={=7*x}D}, {endrepeat}

Thank you! These are very helpful!

1 Like

@Brandt_Weary - Scott has brought it to my attention that in my snippet example, the step where I assign the sequence to the variable is unnecessary in this scenario.

A tighter way of doing this would be as follows:

{formdate: YYYY-MM-DD; name=date}
{repeat: for x in seq(0,52); trim=right}
{time: MMMM Do, YYYY; at={=date}; pattern=YYYY-MM-DD; shift={=7*x}D}, {endrepeat}

1 Like