How do approach this problem?
Write a function points which takes a list L of non negative integers and returns a list of pairs $[x, y]$ where $1 ≤ x ≤$ the length of $L$ and $1 ≤ y ≤ L[x]$.
This is easily done as a nested loop, ie. one loop within another, where the one or both of the end-points of the inner loop will depend upon the current value of the outer loop.
You can use a pair of for-do loops, but then you have to be creative about where to store the list [x,y] that gets generated each time through the inner loop (or be inefficient in memory and repeatedly concatenate with a list of previous pairs). It's easier and efficient to accumulate instead an expression sequence of all the [x,y] pairs using a pair of nested calls to the
The inner loop can determine
The length of a list
Experiment with a pair of nested
Notice that if the right end-point of a range is less that the left end-point then that range is empty: it produces nothing. This comes in handy. For example, the following produces