/* A slow logical implementation of logical association feature. }Value{ = '}{'(Cache,[Value|_]) */ :-op(700,xfy, '<='). :-op(700,xfy, '<+'). :-op(700,yf, '<+'). :-op(700,xfy, '=>'). :-public init_element/1,init_element/2,poke_element/2,peek_element/2. :-public commit_element/1,commit_element/2. :-public (<=)/2, (<+)/2, (<+)/1, (=>)/2. init_element(Elem):-Elem='}{'(_,_). init_element(Elem,Init):- Tail=[Init|_], Elem='}{'(Tail,Tail). Elem<=Value :- poke_element(Elem,Value). poke_element(Elem,Value):- arg(2,Elem,Body), findtail(Body,[_|Tail]), Tail = [Value|_]. % _ makes the new Tail Elem=>Value :- peek_element(Elem,Value). peek_element(Elem,Value):- arg(2,Elem,Body), nonvar(Body), findtail(Body,Tail), arg(1,Tail,Value). Elem<+ :- commit_element(Elem). commit_element(Elem):- peek_element(Elem,Value), commit_element(Elem,Value). Elem<+Value:- commit_element(Elem,Value). commit_element(Elem,Value):- poke_element(Elem,Value). findtail([X|Y],Tail):- nonvar(Y),!, findtail(Y,Tail). findtail(Tail,Tail). % We found the Tail value