## Nesting Structures from Flat Indexes

I don't always use recursion; but when I do, I don't always use recursion.

SQL databases are still one of the best ways of storing relational data, but sometimes you hit a wall transferring your representation to or from a table based layout.

Say we have a table full of Foos, where some Foos may have other Foo parents. This can easily be represented in a table with some unique primary key id, a secondary key parent, which joins to the parent's id, and whatever data Foo may hold. Retrieving this table into a rust data structure, we'd find ourselves with something like Vec<Foo>, where Foo is defined as

struct Foo {
id: i32,
parent: Option<i32>,
data: String,
}


This isn't really the best way to represent these data though, what you really want is more akin to

struct Bar {
id: i32,
data: String,
children: Vec<Bar>,
}


## Clustering Tangent Spheres

Make yourself a little nest of eggs. Where your eggs are perfectly round and magically float in free space.

So you want to do some sphere packing to make your inflatable space habitats for deployment on the Moon and Mars snug and cozy. Perfectly straightforward you think to yourself; since one can start with a triplet of spheres tangent pairwise by placing one at some origin on a 2D plane, extending the second out in the $$x$$ direction and completing the triangle by identifying the third sphere's position based on the radii of all three.