/* assert/retract in Picat. Using B-Prolog's functionality. Note: This usage is not recommended... This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import util. % import cp. main => go. go => bp.assert($play(adam,billiards)), bp.assert($play(eve,billiards)), bp.assert($play(seth,bowling)), bp.assert($play(abel,bowling)), print_all(), nl. go2 => Data = [ [adam,billiards], [eve,billiards], [seth,bowling], [abel,bowling] ], foreach([Who,What] in Data) bp.assert($play(Who,What)) end, print_all(), nl. go3 => Data = [ [adam,billiards], [eve,billiards], [seth,bowling], [abel,bowling] ], Map = new_map([T=1 : T in Data]), foreach([Who,What] in Map.keys()) bp.assert($play(Who,What)) end, print_all(), nl. print_all => while (bp.retract($play(Who,What))) println(Who=What) end, nl.