|Did you know ...||Search Documentation:|
:- use_module(library(prolog_trace)).(can be autoloaded)
fail). The atom
allrefers to all ports. If the port is preceded by a
sign, the trace point is cleared for the port. If it is preceded by a
, the trace point is set. Tracing a predicate is achieved by wrapping the predicate using wrap_predicate/4.
Each time a port (of the 4-port model) is passed that has a trace point set, the goal is printed. Unlike trace/0, however, the execution is continued without asking for further information. Examples:
|Trace all ports of hello with any arity in any module.|
|Trace failures of foo/2 in any module.|
|Stop tracing bar/1.|
?- scanl(plus, [1,2,3,4,5], 0, Sums). Sums = [0, 1, 3, 6, 10, 15].
When considering the lists columns of a table, scanl/5 combines the accumulator with each row to produce the next value in the result list. We illustrate this using plus/4 which adds the accumulator with the values from the row to produce the next accumulator. We use trace/2 to illustrate how the values are combined.
plus(A,B,C,Result) :- Result is A+B+C.
?- trace(plus/4, exit). % plus/4: [exit] ?- scanl(plus, [1,2,3,4,5], [10,20,30,40,50], 0, Sums). T Exit: plus(1, 10, 0, 11) T Exit: plus(2, 20, 11, 33) T Exit: plus(3, 30, 33, 66) T Exit: plus(4, 40, 66, 110) T Exit: plus(5, 50, 110, 165) Sums = [0, 11, 33, 66, 110, 165].