Mapping values in a tuple

4 views
Skip to first unread message

Rasmus Steen

unread,
Mar 26, 2021, 7:05:48 PM3/26/21
to Erlang Questions
I'm trying to write a function that which takes as input a tuple and as its second argument a map which maps atoms to numbers. The function should be like this, 
eval(E,L), wherein E is a tuple of three elements {Op, E1, E2} where Op is a description and E2 is either a number, atom or another tuple consisting of three elements and  map L is a map that acts as lookup table for atoms. 
Example of inputs can be  eval({add, a, b}, #{a => 1, b => 2}) that should map a to 1 and b to 2, or  eval({mul, {add, a, 3}, b}, #{a => 1, b => 2}) that will map a to 1 and b to 2. 
Reply all
Reply to author
Forward
0 new messages