Prolog 与带有列表的 =

发布于 2024-08-06 14:29:06 字数 131 浏览 2 评论 0原文

为什么L is [1,2,3,4]会失败,而L = [1,2,3]却有效?

但是L is 1L = 1两者的工作原理是相同的。

Why does this fail L is [1,2,3,4], and this works: L = [1,2,3]?

But L is 1, and L = 1 both work the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谢绝鈎搭 2024-08-13 14:29:06

is 仅应在计算右侧算术运算时使用。
即:

X is 1 + 2 + 3

is/2 将右侧结构计算为算术表达式。如果它不是有效的算术表达式或数字,则 is/2 失败。否则,算术表达式求值的数字与[可能]未绑定的左侧值统一。

is should only be used when evaluating arithmetic operations on the right-hand side.
i.e.:

X is 1 + 2 + 3

is/2 evaluates the right-hand structure as an arithmetic expression. If it is not a valid arithmetic expression or a number, is/2 fails. Otherwise, the number to which the arithmetic expression evaluted is unified with the [presumably] unbound left-hand value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文