permute_value(pred_false /* bool_false */,P,P,pred_false /* bool_false */).
permute_value(pred_true /* bool_true */,P,P,pred_true /* bool_true */).
permute_value(fd(X,Set),InPerm,OutPerm,PX) :-
((b_global_deferred_set_with_card_gt1(Set)
; is_unused_b_global_constant(Set,X) /* TO DO: only makes sense if more than one unused global constant */
)
-> (member(perm(X,PX,Set),InPerm)
-> OutPerm = InPerm
; OutPerm = [perm(X,PX,Set)|InPerm]
)
; OutPerm=InPerm, PX=fd(X,Set)
).
permute_value(global_set(X),P,P,global_set(X)).
permute_value(freetype(X),P,P,freetype(X)).
permute_value(avl_set(X),In,Out,PermutedList) :-
expand_custom_set_to_list(avl_set(X),Value),
% print(perm(X,Value)),nl,
permute_value(Value,In,Out,PermutedList).
permute_value([],P,P,[]).
permute_value(int(X),P,P,int(X)).
permute_value(term(X),P,P,term(X)).
permute_value(string(X),P,P,string(X)).
permute_value(rec(X),In,Out,rec(PX)) :-
permute_fields(X,In,Out,PX).
permute_value(freeval(I,C,X),In,Out,freeval(I,C,PX)) :-
permute_value(X,In,Out,PX).
permute_value([H|T],In,Out,[PH|PT]) :-
permute_value(H,In,In2,PH),
permute_value(T,In2,Out,PT).
permute_value((H,T),In,Out,(PH,PT)) :-
permute_value(H,In,In2,PH),
permute_value(T,In2,Out,PT).
permute_value(closure(X,Y,Z),P,P,closure(X,Y,Z)).
permute_value(closure_x(X,Y,Z,E),P,P,closure_x(X,Y,Z,E)).
permute_value(abort(Err),P,P,abort(Err)) :- print(deprecated_abort_in_permute_value(Err)),nl.