A.21 library(intercept): Intercept and signal interface
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(intercept): Intercept and signal interface
          • intercept/3
          • intercept/4
          • intercept_all/4
          • nb_intercept_all/4
          • send_signal/1
          • send_silent_signal/1
    • Packages
Availability::- use_module(library(intercept)).(can be autoloaded)
Sourceintercept_all(+Template, :Goal, ?Ball, -List)
True when List contains all instances of Template that have been sent using send_signal/1 where the argument unifies with Ball. Note that backtracking in Goal resets the List. For example, given
enum(I, Max) :- I =< Max, !, send_signal(emit(I)),
                I2 is I+1, enum(I2, Max).
enum(_, _).

Consider the following queries

?- intercept_all(I, enum(1,6), emit(I), List).
List = [1, 2, 3, 4, 5, 6].

?- intercept_all(I, (between(1,3,Max),enum(1,Max)),
                 emit(I), List).
Max = 1, List = [1] ;
Max = 2, List = [1, 2] ;
Max = 3, List = [1, 2, 3].
See also
nb_intercept_all/4