Prolog 99 瓶啤酒

问题描述

以下代码查询不起作用:

bottles(X) :-
    write(X),write(' bottles of beer on the wall,'),nl,write(X),write(' bottles of beer,write('Take one down,and pass it around,X1 is X - 1,write(X1),write(' bottles of beer on the wall.'),bottles(X1).
bottles(1) :-
    write('1 bottle of beer on the wall,1 bottle of beer,write('Now they are alle gone.'),nl.

?- bottles(99).

在 Windows 上使用 SWI-Prolog 8.3.15 我什至不能按 Ctrl-C。

怎么了?

解决方法

它会一直递归下去,因为第一条规则从来没有说 library(vroom) temp <- tempfile() download.file("https://files.consumerfinance.gov/hmda-historic-loan-data/hmda_2017_nationwide_all-records_labels.zip",temp) unzip(temp,"hmda_2017_nationwide_all-records_labels.csv") df2017 <- vroom("hmda_2017_nationwide_all-records_labels.csv") unlink(temp) 应该大于 1。因此,您可以通过以下方式解决此问题:

X