A binary algebra describing crystal structures with closely packed anions