Inserts the compound term Struct into the ordered list Old, giving New. The lists are both in strictly ascending order (according to their elements' Key'th argument), i.e. without duplicates. If Old already contains an element with the same key as Struct, then Struct replaces this existing element. Otherwise, Struct is inserted at the correct position to maintain the list order.
The list New is either of the same length as Old, or one longer.
?- update(1, f(2,b), [f(1,a),f(3,c)], New).
New = [f(1,a), f(2,b), f(3,c)]
Yes (0.00s cpu)
?- update(1, f(2,new), [f(1,a),f(2,b),f(3,c)], New).
New = [f(1,a), f(2,new), f(3,c)]
Yes (0.00s cpu)