[Up] [Contents] [Index] [Summary]
SWI-Prolog offers a query substitution mechanism similar to that of
Unix csh (csh(1)), called `history'. It allows the user to compose new
queries from those typed before and remembered by the system. It also
allows to correct queries and syntax errors. SWI-Prolog does not offer
the Unix csh capabilities to include arguments. This is omitted as it is
unclear how the first, second, etc. argument should be defined. (3)
The available history commands are shown in table
1.
Figure 1 gives some examples.
!!. | Repeat
last query |
!nr. | Repeat query numbered<nr> |
!str. | Repeat last query starting with<str> |
!?str. | Repeat last query holding<str> |
^old^new. | Substitute<old>into<new>of
last query |
!nr^old^new. | Substitute in query
numbered<nr> |
!str^old^new. | Substitute in query
starting with<str> |
!?str^old^new. | Substitute in query
holding<str> |
h. | Show history list |
!h. | Show this list |
Table 1 : History commands
/staff/jan/.plrc consulted, 0.066667 seconds, 591 bytes
Welcome to SWI-Prolog (Version \plversion)
Copyright (c) 1993-1996 University of Amsterdam. All rights reserved.
For help, use ?- help(Topic). or ?- apropos(Word).
1 ?- append("Hello ", "World", L).
L = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
Yes
2 ?- !!, writef('L = %s\n', [L]).
append("Hello ", "World", L), writef('L = %s\n', [L]).
L = Hello World
L = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
Yes
3 ?- sublist(integer, [3, f, 3.4], L).
L = [3]
Yes
4 ?- ^integer^number.
sublist(number, [3, f, 3.4], L).
L = [3, 3.400000]
Yes
5 ?- h.
1 append("Hello ", "World", L).
2 append("Hello ", "World", L), writef('L = %s\n', [L]).
3 sublist(integer, [3, f, 3.4], L).
4 sublist(number, [3, f, 3.4], L).
5 ?- !2^World^Universe.
append("Hello ", "Universe", L), writef('L = %s\n', [L]).
L = Hello Universe
L = [72, 101, 108, 108, 111, 32, 85, 110, 105, 118, 101, 114, 115, 101]
Yes
6 ?- halt.
Figure 1 : Some examples of the history facility
Section Index