I to need modify the values {place} and {other_place} in the op record.
#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]]
}
But erlang don´t allow modifying variables. Is there a data type for that?
erlang doesn't let you modify variables it is true. But nothing prevents you from making modified copies of a variable.
Given your record:
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]]
}
You can effectively get a modified version like so:
%% 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}]}
This will accomplish what you seem to be asking.
精彩评论