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
    
    
    Run

Reply via email to