I am trying to create a object to bound the Nat and Text variables in Motoko
For example,
let obj:[(Nat,Text)] = [(0,"a"),(1,"b")];
func foundTextbyNat(_input:Nat):Text;
func foundNatbyText(_input:Text):Nat;
the func foundTextbyNat(_input:Nat):Text; can be done by initializing a obj_map:HashMap.HashMap<Nat, Text> = HashMap.fromIter(obj.vals(), 0, Nat.equal, Hash.hash);, but how about the sec one? Any idea how to create a inversed HashMap? (Hardcode obj2:[(Text,Nat)] = [("a",0),("b",1)]; is NOT a solution since the obj must be dynamic variable)
Furthermore, any data structure we can use to directly create a bijective map? Given key Nat return associated Text and Given key Text return associated Nat.
Thank.