Question: Write a function go/3 as described above. You should use the functions above for this. The go/3 function will be called by a new version

Write a function go/3 as described above.

You should use the functions above for this.

The go/3 function will be called by a new version of islegal/2. Here's the old one:

islegal(Str) :? string_chars(Str,Cs), start(State), go(State,Cs).

Here's the new one:

In [ ]:

%%CONSULTislegal(F,S) :- string_chars(S,Cs), getinitial(F,I), go(F,I,Cs).

(Make sure to "run" that cell so you can use it.)

Here is the old go/2 function.

go(State,[]) :? final(State), !.go(State,[C|Str]) :? arc(State,C,Otherstate), go(Otherstate,Str).

Now write go/3.

In [ ]:

%%CONSULT%Your code here

In [ ]:

islegal( fsa(initial(1),final([3]),arcs([arc(1,a,2),arc(2,b,3)])), "ab").

In [ ]:

islegal( fsa(initial(1),final([3,1]),arcs([arc(1,a,2),arc(2,b,3)])), "").

In [ ]:

+islegal( fsa(initial(1),final([3]),arcs([arc(1,a,2),arc(2,b,3)])), "abc").

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below To implement the go3 function we will u... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!