Use loops to place a pile of entities atop one another.
This is the code to spawn a pig.
In order to use it, we need a world and a location
Type the following two lines into chat to set up these variables.
Now we can use the above command to spawn a pig at that location in that world
Note that every time we reset the world we will need to recreate these variables