v.01
{ x: 10, foo: 20, bar: "foo + x", baz: "bar^2" }
%mathpiper
list := '[ x: 10, foo: 20, bar: (foo + x), baz: (bar^2)];
length := Length(list);
index := 1;
While(index <=? length)
{
element := list[index];
Echo("Substitute '" + element[2] + "' for '" + element[1] + "' in " + list);
list := Substitute(element[1], element[2]) list;
Echo("result: " + list); Echo();
index++;
}
Eval(list);
%/mathpiper
%output,mpversion=".235",preserve="false"
Result: [10:10,20:20,(20 + 10):30,((20 + 10)^2):900]
Side Effects:
Substitute '10' for 'x' in [x:10,foo:20,bar:(foo + x),baz:(bar^2)]
result: [10:10,foo:20,bar:(foo + 10),baz:(bar^2)]
Substitute '20' for 'foo' in [10:10,foo:20,bar:(foo + 10),baz:(bar^2)]
result: [10:10,20:20,bar:(20 + 10),baz:(bar^2)]
Substitute '20 + 10' for 'bar' in [10:10,20:20,bar:(20 + 10),baz:(bar^2)]
result: [10:10,20:20,(20 + 10):(20 + 10),baz:((20 + 10)^2)]
Substitute '(20 + 10)^2' for 'baz' in [10:10,20:20,(20 + 10):(20 + 10),baz:((20 + 10)^2)]
result: [10:10,20:20,(20 + 10):(20 + 10),((20 + 10)^2):((20 + 10)^2)]
. %/output