If I've got a table for which I know (by construction) the keys and values are unique, is there a more elegant way to "invert" the table than below?
import tables, sequtils
var int2str = {0: "Zero", 1: "One", 2: "Two", 3: "Three"}.toTable
var str2int = newTable(zip(toSeq(int2str.values), toSeq(int2str.keys)))
Dunno if more elegant or not, but you can try using mapIt
import tables, sequtils
var int2str = {0: "Zero", 1: "One", 2: "Two", 3: "Three"}.toTable
var str2int = toSeq(int2str.pairs).mapIt((it[1], it[0])).toTable