ch18ex10.pro

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

PRO
32
字号
/*
   Turbo Prolog 2.0 Chapter 18, Example Program 10
   
   Copyright (c) 1986, 88 by Borland International, Inc
   
*/
   
predicates
   wait(char)
   equal(char, char)
   test(string)

goal
   makewindow(3, 7, 0, "", 0, 0, 25, 80),
   makewindow(2, 7, 7, "Key to press now", 2, 5, 6, 70),
   makewindow(1, 7, 7, "Accepted letters", 8, 10, 10, 60),
   Word = "Peter Piper picked a peck of pickled peppers",
   write("Please type :\n\t", Word,"\n\t"),
   time(0, 0, 0, 0), test(Word),
   time(_, _, S, H),
   shiftwindow(1),
   write("\nYou took ", S, " seconds and ", H, " hundredths").

clauses
   wait(X) :- inkey(Y), equal(X, Y).
   wait(X) :- shiftwindow(2), write(X), wait(X).
   test(W) :- frontchar(W, Ch, R), wait(Ch),
              shiftwindow(2), write(Ch), test(R).
   test("").
   equal(X, X) :- !.
   equal(_, _) :- beep, fail.

⌨️ 快捷键说明

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