In swi-prolog I can do such thing "sentence --> nounphrase, verbphrase."
The "-->" which is called DCG(Definite Clasue Grammer).
and in swi-prolog I can take ";" as "if else" to use.
Whether can visual prolog do things like above?
Code: Select all
sentence --> nounphrase, verbphraseCode: Select all
clauses
    sentence(S1, S0) :-
        nounphrase(S1, S2), 
        verbphrase(S2, S3),
        S0 = S3. % S0 is normally used directly instead of S3Code: Select all
sentence --> nounphrase, {action}, verbphraseCode: Select all
clauses
    sentence(S1, S0) :-
        nounphrase(S1, S2),
        action(),
        verbphrase(S2, S0).Code: Select all
sentence --> ["The"], nounphrase, {action}, verbphraseCode: Select all
clauses
    sentence(S1, S0) :-
        ["The"|S2] = S1,
        nounphrase(S2, S3),
        action(),
        verbphrase(S3, S0).Code: Select all
clauses
    sentence(S1, S0) :-
        match(["The"], S1, S2),
        nounphrase(S2, S3),
        action(),
        verbphrase(S3, S0).Code: Select all
sentence(sentence(N,V)) --> ["The"], nounphrase(N), {action}, verbphrase(V)Code: Select all
clauses
    sentence(sentence(N,V), S1, S0) :-
        match(["The"], S1, S2),
        nounphrase(N, S2, S3),
        action(),
        verbphrase(V, S3, S0).Code: Select all
clauses 
    fact(N, F) :- 
        (N <= 1, !, F = 1); 
        (fact(N-1, F1), F = F1 * N).Code: Select all
clauses 
    fact(N, F) :- 
        if N <= 1 then
            F = 1)
        else
            fact(N-1, F1),
            F = F1 * N
       end if.Code: Select all
class predicates
    fact : (integer N) -> integer Fac.
clauses
    fact(N) = F :-
        if N <= 1 then
            F = 1
        else
            F = N * fact(N-1)
        end if.Code: Select all
class predicates
    fact : (integer N) -> integer Fac.
clauses
    fact(N) = if N <= 1 then 1 else N * fact(N-1) end if.