Enumerate points in a 2d and 3D triangular grid I have the pairs $[i, j]$ with $i, j = 1,...,n$ and $j > i$. I know that there are $\frac{n(n-1)}{2}$ possible pairs. 
Is there a function $f_2(l) \rightarrow [i,j]$, $l=1,...,\frac{n(n-1)}{2}$ that returns all these pairs?
As above, but triples $[i, j, k]$ with $i,j,k=1,...,n$ and $k > j > i$. Number of triples is $\frac{n(n-1)(n-2)}{6}$.
Is there a function $f_3(l) \rightarrow [i,j,k]$ that returns all triples?
 A: I'm going to give you what you asked for and a little more that you didn't ask for (but may have been expecting). If you don't see what you want, you might consider editing the question to clarify your needs.
First version
For $f_2(l),$ arrange all pairs $[i,j]$ such that $1 \leq i < j \leq n$
in sequence such that $[i_1, j_1]$ is before $[i_2, j_2]$ if and only if one of the following two statements is true:
(a) $j_1 < j_2$ or (b) $j_1 = j_2$ and $i_1 < i_2.$
Then $f_2(l)$ is the $l$th pair in the sequence.
For $f_3(l),$ arrange all triples $[i,j,k]$ such that 
$1 \leq i < j <k \leq n$
in sequence such that $[i_1, j_1, k_1]$ is before $[i_2, j_2, k_2]$ if and only if one of the following three statements is true:
(a) $k_1 < k_2,$ (b) $k_1 = k_2$ and $j_1 < j_2,$
(c) $k_1 = k_2,$ $j_1 = j_2,$ and $i_1 < i_2.$
Then $f_3(l)$ is the $l$th triple in the sequence.
There are other functions that can be obtained by changing the sequences of pairs or triples.
Second version
$f_2(l) = [i,j]$ where
\begin{align}
j &= \min\{t \in \mathbb N : \tfrac12 t(t-1) \geq l\}, \\
i &= l - \tfrac12 (j-1)(j-2).
\end{align}
$f_3(l) = [i,j,k]$ where
\begin{align}
k &= \min\{t \in \mathbb N : \tfrac16 t(t-1)(t-2) \geq l\}, \\
[i,j] &= f_2\left(l - \tfrac16 (k-1)(k-2)(k-3)\right).
\end{align}
Computing the functions
It is easy enough to come up with a computational algorithm for the first version of the functions. A nested loop can construct the sequence of pairs or triples in the order specified by those definitions, without needing to sort them afterward. For example, to generate a list of triples in python,
triples = []
for k in range(3, n + 1):
    for j in range(2, k):
        for i in range(1, j):
           triples.append([i, j, k])

But it may take a long time and a lot of memory to build the list.
If you construct the list once and then call $f_2$ or $f_3$ many times,
the amortized cost may be small enough; otherwise you probably want something more efficient.
For the second version, you need some way to compute $j$ for $f_2$
and $k$ for $f_3.$
An obvious approach is to start with the smallest possible value of $t$
and count up until you find the correct value.
This is not as bad as it sounds, because $\tfrac12 t(t-1)$ grows like $t^2$
and $\tfrac16 t(t-1)(t-2)$ grows like $t^3$; computed this way, the computational complexity of $f_2$ is $O(\sqrt n)$ and that of
$f_3$ is $O(\sqrt[3] n).$
Even better, there is a relatively straightforward closed-form formula for $j$ in $f_2,$ which you can deduce from the answer to
Largest Triangular Number less than a Given Natural Number.
There is even a closed-form formula for $k$ in $f_3,$ though I would not like to use it:
$$
k = \frac{(\sqrt3 \sqrt{243 n^2 - 1} + 27 n)^{1/3}}{3^{2/3}} 
+ \frac{1}{{3^{1/3} (\sqrt3 \sqrt{243 n^2 - 1} + 27 n)^{1/3}}} + 1
$$
A simpler but still efficient approach, I think, is to estimate a preliminary value of $k$, say $k_1 = 1 + \sqrt[3]{6l},$
and then increase or decrease the value until it is correct.
