gpt4 book ai didi

prolog - 使用序言打印偶数 :

转载 作者:行者123 更新时间:2023-12-02 08:19:34 26 4
gpt4 key购买 nike

如何在 Prolog 中只打印偶数?这是我打印从 3 到 1 的数字的代码:以及如何在另一个示例中使用不带 (*) 的 mult:

predicates
count(integer).
clauses
count(1) :- write(1), nl, !.
count(X) :- X > 1, write(X), nl, X1 = X-1, count(X1), !.

最佳答案

How can I print just even numbers in Prolog

?- between(1, 3, X), X mod 2 =:= 0.
X = 2.

关于prolog - 使用序言打印偶数 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19875058/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com