如果您使用的是 SWI-Prolog,您可以使用标志toplevel_print_anon
) 来控制它。但是,由单个下划线 ( _
) 组成的名称是特殊的并且从不打印。
$ swipl dd.pl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.16)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- set_prolog_flag(toplevel_print_anon, true).
true.
?- vegetarian(_X).
_X = jose ;
_X = james.
?- vegetarian(_).
true ;
true.
?- set_prolog_flag(toplevel_print_anon, false).
true.
?- vegetarian(_X).
true ;
true.