I think I already know the answer, but I wanted to make sure. I create a dictionary to work as a static lookup table (i.e. the Dictionary will be unchanged after its creation) and find that this serves the purpose:
L = [{keyA, "A"}, {keyB, "B"}, {keyC, "C"}].
D = dict:from_list(L).
V = dict:fetch(keyA, D).
Is this an acceptable method, or is there some other magic that I am not familiar with yet?
As a continuation, if I were to create a mutable dictionary, do I really need to accept frauds like
D = dict:from_list(L).
D1 = dict:append(keyD, "D", D).
And finally, instead of passing the dictionary around the function from function to function, is there persistent storage that I can save and extract from it along the lines of the procedure register/2- whereis/1?
source
share