SWI-Prolog offers a query substitution mechanism called `history'.
The availability of this feature is controlled by set_prolog_flag/2,
using the history
Prolog flag. By default, history is available if the Prolog flag readline
is false
. To enable this feature, remembering the last 50
commands, put the following into your startup file (see section
2.2):
:- set_prolog_flag(history, 50).
The history system allows the user to compose new queries from those typed before and remembered by the system. The available history commands are shown in table 1. History expansion is not done if these sequences appear in quoted atoms or strings.
!!. | Repeat last query |
!nr. | Repeat query numbered <nr> |
!str. | Repeat last query starting with <str> |
h. | Show history of commands |
!h. | Show this list |
Table 1 : History commands |