Why do circular references and recursion make my program fail?

后端 未结 4 1265
耶瑟儿~
耶瑟儿~ 2021-01-14 10:28

I wrote this simple Prolog program.

man(socrates).
mortal(X) :- man(X).
immortal(X) :- immortal(X).

I asked it the usual questions, such as

4条回答
  •  温柔的废话
    2021-01-14 11:26

    How about this little program:

     loopy(Y) :- read(X), Z is X+Y, print(Z), nl, loopy(Y).
    

    Your Mr. Prolog would infer, that loopy(Y) has already been called and would fail.

提交回复
热议问题