erlang 不允许你修改变量,这是事实。但没有什么可以阻止您制作变量的修改副本。
鉴于您的记录:
Rec = #op{
action = [walk, from, {place}, to, {other_place}],
preconds = [[at, {place}, me], [on, floor, me],
[other_place, {place}, {other_place}]],
add_list = [[at, {other_place}, me]],
del_list = [[at, {place}, me]]
}
您可以有效地获得修改后的版本,如下所示:
%% replaces the action field in Rec2 but everything else is the same as Rec.
Rec2 = Rec#op{action = [walk, from, {new_place}, to, {new_other_place}]}
这将完成你似乎要求的事情。