It's pretty easy to create loop with help of mathematica
Let's say i want to scale a ball in 3d space
i want it to
start as original one
than get bigger and bigger as time goes by
when it's big enough, i want it to stay there for a few while,
then i want it to get smaller and smaller as time goes by
when it's small enough, i want it to stay there for a few while
........
I can draw this transform in mathematica like this:
Plot[{Sin[t ] + 1, y = 1.5, y = 0.5}, {t, 0, 6 Pi}]
It's pretty easy to write our loop as
max( min(Sin[t ] + 1, 0.5 ), 1.5)
This case is pretty simple, it will be more valuable if your loop is complicated.
And it's middle school knowledge.