How can I map associations to expressions?
You can simply use your association as a list of rules to be passed to ReplaceAll
, also known as /.
.
expr = -0.0441268 (-0.905134 - f + (3.24967 + p)^0.638117)
assoc = <|a -> -0.497445, b -> -0.12459, c -> 0.59053, d -> 0.26936,
e -> 0.745094, f -> -0.225087, g -> 0.744386, h -> 0.915999,
i -> 0.540287, j -> 0.406811, k -> -0.664433, l -> 0.355135,
m -> -0.880653, n -> -0.559651, o -> -0.23426, p -> 0.260966,
q -> 0.435459, r -> -0.105631, s -> 0.544961, t -> 0.347138,
u -> 0.958919, v -> 0.200587, w -> -0.656598, x -> 0.553327,
y -> -0.282113, z -> 0.178719|>
Now
expr /. assoc
or
ReplaceAll[expr, assoc]
will give you the answer, in this case -0.0683299
.
Also
With[{f = assoc[f], p = assoc[p]}, Evaluate @ expr]
-0.0683299