什么是Prolog运算符"^"(“插入符")? [英] What is the Prolog operator `^` ("caret")?

查看:141
本文介绍了什么是Prolog运算符"^"(“插入符")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是Prolog运算符^?

What is the Prolog operator ^ ?

查看 Prolog内置指令op 给出了内置运算符的列表.

Looking at The Prolog Built-in Directive op gives a list of the built-in operators.

我知道

  • **求幂
  • /\
  • ** is exponentiation
  • /\ is or

但是^是什么?

当前三个答案中的每一个都是有价值的,我学到了一些东西:

Each of the three current answers are of value and I learned something:

  • 这本书的罗伊
  • 示例错误
  • 我接受CapelliC的回答,因为它清楚表明^/2具有多种含义
    视情况而定,这立即消除了我的困惑.
  • Roy for the book
  • false for the examples
  • I accepted the answer by CapelliC because it made clear that ^/2 has multiple meanings
    depending on context which instantly cleared up my confusion.

推荐答案

在Prolog中,大多数符号可以在语法级别未解释"使用,尤其是在op/3声明之后,任何原子都可以用作操作员.然后,您可以使用^/2作为域特定语言(DSL)的函数构造函数,并使用规则中指定的语义.

In Prolog, most symbols can be used 'uninterpreted', at syntactic level, in particular after an op/3 declaration, any atom can be used as operator. Then you can use, for instance, ^/2 as a function constructor for a domain specific language (a DSL), with a semantic specified from your rules.

是SWI-Prolog(或更常见的是ISO Prolog),current_op/3为您提供有关已声明的运算符的信息:

Is SWI-Prolog (or more generally in ISO Prolog), current_op/3 gives you information about declared operators:

?- current_op(X,Y,^).
X = 200,
Y = xfy. 

也就是说,在装饰2 nd 参数时,任何实现setof/3的Prolog都应将^/2解释为量化说明符.同样,当任何实现is/2的Prolog出现在is/2表达式的右侧时,都应该将^/2解释为幂.

That said, any Prolog implementing setof/3 is expected to interpret ^/2 as a quantification specifier, when put to decorate the 2nd argument. As well, any Prolog implementing is/2 is expected to interpret ^/2 as exponentiation, when occurring on the right side of the is/2 expression.

这篇关于什么是Prolog运算符"^"(“插入符")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆