ans_155.pro

来自「prolog,人工智能推理程序,运行环境prolog」· PRO 代码 · 共 29 行

PRO
29
字号
/*
   Turbo Prolog 2.0, Answer to Exercise on page 155.
   
   Copyright (c) 1986, 88 by Borland International, Inc
*/
   
% Uses backtracking to print all solutions to a query.

Predicates
   country(symbol,real)
   %      (name  ,population)  
   print_countries

Clauses
   country(england,3e7).
   country(france,2.3e7).
   country(germany,1.6e7).
   country(denmark,2.4e6).
   country(canada,7.3e6).
   country(chile,2.5e).

   print_countries :- 
   	country(X,P),     /* bind country name to X and population to P */
   	P > 1e7,          /* is population greater than 10 million? */
        write(X),         /* write the value of X */
        nl,               /* start a new line */
        fail.             /* force backtracking to find all solutions */
   print_countries.       /* make sure print_countries succeeds */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?