Freeze with dictionaries

Based on my question here unfortunately another question has raised today. I have some dictionary and want to add different key-values on it.

My code so far:


?- use_module(library(clpfd)).
true.

?- X #= Y+1, freeze(Y, A=ara{1:[3]}.put([Y=[2]])), freeze(B, B = A.put([5=33])), Y#=1.
X = 2,
Y = 1,
A = ara{1:[2]},
freeze(B,  ('.'(ara{1:[2]}, put([5=33]), _115810), B=_115810)).

but my desired output was:

B=ara{1:[2], 5:33}

what could be the reason the output here is such cryptic and how could I solve it?

Instead of freeze(B :

?- X #= Y+1, freeze(Y, A=ara{1:[3]}.put([Y=[2]])), freeze(A, B = A.put([5=33])), Y#=1.
X = 2,
Y = 1,
A = ara{1:[2]},
B = ara{1:[2],5:33}.

The _115810 is a “system” variable without a value.

For this example, CLPFD is not needed, can add another freeze instead:

?- freeze(Y, X is Y+1), freeze(Y, A=ara{1:[3]}.put([Y=[2]])), freeze(A, B = A.put([5=33])), Y=1.
Y = 1,
X = 2,
A = ara{1:[2]},
B = ara{1:[2],5:33}.
1 Like