level 3
anda1024123
楼主
最近开始学prolog. 有个题目不太懂,求帮忙!题目如下。
用list来表示一个序列(所以,空序列就是[])。编译一个accpet/1的谓词 要求是跟随的序列附着在下面 a|b|c)a^*(b^+c^*)^* 式子.
Representing sequences by lists (and, thus, the empty sequence by []),
encode a predicate accept/1 which succeeds for sequences that
adhere to the pattern represented by the following regular expression:
(a|b|c)a^*(b^+c^*)^*.
提示,(x|y)代表了任何被x,y所代表的的式子。x^+代表了任何的x所产生的结果。x^*就是比x^+多了一个空序列
As a reminder, expression (x|y) represents any of the expressions
represented by x or y. Expression x^+ represents any expression
resulting from the concatenation of the expressions represented by
x. Expression x^* represents the same as x^+ and also the empty
sequence.
假设是从左到右执行的,那下面的两个式子 那个更有效
Assuming left-to-right execution, which of the following two queries
is more efficient? Justify your answer.
2013年05月23日 14点05分
1
用list来表示一个序列(所以,空序列就是[])。编译一个accpet/1的谓词 要求是跟随的序列附着在下面 a|b|c)a^*(b^+c^*)^* 式子.
Representing sequences by lists (and, thus, the empty sequence by []),
encode a predicate accept/1 which succeeds for sequences that
adhere to the pattern represented by the following regular expression:
(a|b|c)a^*(b^+c^*)^*.
提示,(x|y)代表了任何被x,y所代表的的式子。x^+代表了任何的x所产生的结果。x^*就是比x^+多了一个空序列
As a reminder, expression (x|y) represents any of the expressions
represented by x or y. Expression x^+ represents any expression
resulting from the concatenation of the expressions represented by
x. Expression x^* represents the same as x^+ and also the empty
sequence.
假设是从左到右执行的,那下面的两个式子 那个更有效
Assuming left-to-right execution, which of the following two queries
is more efficient? Justify your answer.