2.8 Reuse of top-level bindings

Bindings resulting from the successful execution of a top-level goal are asserted in a database. These values may be reused in further top-level queries as $Var. Only the latest binding is available. Example:

1 ?- maplist(plus(1), "hello", X).

X = [105,102,109,109,112] 

Yes
2 ?- format('~s~n', [$X]).
ifmmp

Yes
3 ?-
Figure 1 : Reusing top-level bindings

Note that variables may be set by executing =/2:

6 ?- X = statistics.

X = statistics

Yes
7 ?- $X.
28.00 seconds cpu time for 183,128 inferences
4,016 atoms, 1,904 functors, 2,042 predicates, 52 modules
55,915 byte codes; 11,239 external references

                      Limit    Allocated       In use
Heap         :                                624,820 Bytes
Local  stack :    2,048,000        8,192          404 Bytes
Global stack :    4,096,000       16,384          968 Bytes
Trail  stack :    4,096,000        8,192          432 Bytes

Yes
8 ?-