prolog - SWISH Prolog 阶乘误差
问题描述
fact(0,1).
fact(N,F):-
(
N>0:-
( N1 is N-1,
fact(N1,f1),
F is N*F1
)
;
write("N less than 0 nor allowed")
).
在本教程中,作者的代码正在运行。我编写了相同的代码,但我的代码不起作用。他正在用 cgwin(即离线)写作,而我正在用 SWISH(即在线)写作。
查询已通过:fact(3,R).
错误消息:
Singleton variables: [R]
Singleton variables: [F1]
procedure `(A:-B)' does not exist
Reachable from:
fact(A,B)
解决方案
推荐阅读
- python - 如何将 Numpy Eig 与 Python Lambda 函数一起使用?
- amazon - AWS Neptune - 之间的中心性计算
- neo4j - Cypher 通过关系和节点的模式返回多个跃点
- java - 当我从片段 A 到 B 然后从片段 B 回到 A 时,如何避免重新创建片段 A
- python - 无法使用 disable_eager_execution 加载 keras 模型
- kiwi-tcms - KiwiTCMS 10.0 的附件失败并出现错误 500
- date - 从文本 YYYY/MM 到 DATETIME20 的 SAS 日期转换。格式
- ios - Firebase Auth 在不同设备上使用验证电子邮件登录
- php - 我正在尝试在 Laravel 中制作匹配生成器。但是每个团队在输出中出现两次
- google-ads-api - google ads api中频繁出现“invalid_grant:令牌已过期或撤销”的原因可能是什么