mapping implemented in functions vs in structures
HP Wei
hp@REDACTED
Fri Apr 25 00:10:25 CEST 2003
I want to map entity x1 on machine m1 to y1 on m2 ...
I can see there are two choices and don't know which one
is the more idiomatic way in erlang world:
(1) functions
m1_m2(x1) -> y1;
m1_m2(x2) -> y2.
m3_m6(a1) -> b1;
m3_m6(a2) -> b2....
At run time,
suppose A = m1, B = m2, X = x1.
To get y1,
I will need to form a string S ="m1_m2(x1)"
and evaluate it.
btw, how do I do this ? erl_eval:expr() looks complicated.
(2) structures
{{m1_m2, [{x1, y1},
{x2, y2}]},
{m3_m6, [{a1, b1},
{a2, b2}]}
Given A, B, X in (1), finding y1 becomes
a matter of parsing the structure.
thanks,
HP
More information about the erlang-questions
mailing list