新人 ,prolog 求助帮忙。
prolog吧
全部回复
仅看楼主
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
level 3
anda1024123 楼主

?- accept(【b,a,a,a,b】).
?- accept(X), X=【b,a,a,a,b】
Decide whether your code for accept/1 can be best regarded as a
table-based or a code-based implementation of the corresponding
automaton. Justify your answer.
(Note: This part scores higher if your implementation does not follow
that of the course slides for automata.)
2013年05月23日 15点05分 2
level 3
anda1024123 楼主
@真实之魇 求高手指点下。
2013年05月23日 15点05分 3
1